宝石安装错误版本的捆绑器

时间:2018-10-29 09:07:09

标签: ruby-on-rails ruby rubygems bundle bundler

我在使用Bundler(bundle cannot load such file bundler-1.17.1/exe/bundle)时遇到问题,因此我删除了Bundler,然后手动删除了所有捆绑器目录:

gem uninstall bundler -x

gem cleanup bundler

然后用rm -rf从以下位置删除:

~/.gem/ruby/2.5.1/gems/bundler-1.17.1

~/.rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.17.1

~/.bundle

现在,我想使用默认版本1.17.1重新安装捆绑程序。 所以我尝试了gem install bundler

gem install bundler
Fetching: bundler-1.17.1.gem (100%)
Successfully installed bundler-1.17.1
Parsing documentation for bundler-1.17.1
Installing ri documentation for bundler-1.17.1
Done installing documentation for bundler after 3 seconds
1 gem installed

如果我尝试执行bundle命令,则会出现此错误:

bundle
Traceback (most recent call last):
    1: from /Users/robin/.gem/ruby/2.5.1/bin/bundle:23:in `<main>'
/Users/robin/.gem/ruby/2.5.1/bin/bundle:23:in `load': cannot load such file -- /Users/robin/.rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.17.1/exe/bundle (LoadError)

我可以在~/.gem/ruby/2.5.1/gems/bundler-1.17.1中看到bundler-1.17.1,但在.rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.17.1中看不到。所以我必须手动复制文件夹:

cp -R ~/.gem/ruby/2.5.1/gems/bundler-1.17.1 ~/.rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.17.1

但是现在,如果我尝试使用bundle命令,它可以工作,但是我在第一行中显示以下消息:

Warning: the running version of Bundler (1.16.2) is older than the version that created the lockfile (1.16.6). We suggest you upgrade to the latest version of Bundler by running 'gem install bundler'.

我尝试通过gem install bundler -v 1.17.1安装捆绑程序,但是仍然存在问题。

宝石列表输出:

gem list bundler

*** LOCAL GEMS ***
bundler (default: 1.17.1)
capistrano-bundler (1.4.0, 1.3.0)

我的配置:

macOS 10.13.6

ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]

chruby
   ruby-2.5.0
 * ruby-2.5.1

rails -v
Rails 5.2.1

gem -v
2.7.7

编辑:

我忘记指定gem pristine bundler不适用于捆绑器:

gem pristine bundler
Restoring gems to pristine condition...
Skipped bundler-1.17.1, it is a default gem

如果我尝试两次卸载捆绑程序,则会收到此消息:

gem uninstall bundler -x
ERROR:  While executing gem ... (Gem::InstallError)
    gem "bundler" cannot be uninstalled because it is a default gem

所以我不知道捆绑器是否真的是第一次卸载。

0 个答案:

没有答案