即使不在 Gemfile 中,“bundle install”也会继续安装 gem sqlite3 版本 1.4.2

问题描述

我需要为我的应用安装 sqlite3 v1.3.9 gem,所以我将这一行添加到 Gemfile:

gem 'sqlite3','= 1.3.9'

但是,当我运行“捆绑安装”时,它会安装该 gem 的 v1.4.2。

我将上面的行修改为

gem 'sqlite3','= 1.3.9','< 1.4'

不高兴 -- 安装了 sqlite v1.4.2(即使我从 Gemfile 中完全删除了对“sqlite3”的任何引用)。

我的 Gemfile 是在我使用 rails new appname 时创建的,所以它一点也不花哨......我只是在其中添加了 gem devise

Gemfile.lock 不包含对 sqlite3 的任何引用。无论如何,我将其删除,但没有帮助。

作为另一种选择,我通过 gem install sqlite3 -v 1.3.9 安装了 v1.3.9,并使用

删除了 v1.4.2
# bundle exec gem uninstal sqlite3

Select gem to uninstall:
 1. sqlite3-1.3.9
 2. sqlite3-1.4.2
 3. All versions
> 2
Successfully uninstalled sqlite3-1.4.2

...但是当我尝试添加 v1.3.9 时,我得到了:

# bundle add sqlite3 -v 1.3.9

[!] There was an error parsing `injected gems`: You cannot specify the same gem twice with different version requirements.
You specified: sqlite3 (~> 1.4) and sqlite3 (= 1.3.9). Bundler cannot continue.

 #  from injected gems:1
 #  -------------------------------------------
 >  gem "sqlite3","= 1.3.9"
 #  -------------------------------------------

我非常感谢您提供有关为何不断安装 v1.4.2 的任何提示,最重要的是,如何让打包程序忘记 v1.4.2 并接受 v1.3.9?

非常感谢!

解决方法

您的应用中可能有一些 gem 需要 sqlite3-1.4.2,这会导致安装 sqlite3-1.3.9 出现问题。您应该检查您的 Gemfile.lock 并查找任何将 sqlite3-1.4.2 添加为依赖项的 gem。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...