捆绑器:在使用 gem 进行捆绑安装期间找不到带有可执行捆绑 (Gem::GemNotFoundException) 的 gem 捆绑器 (>= 0.a) [英] Bundler: can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException) during bundle install with gem

查看:24
本文介绍了捆绑器:在使用 gem 进行捆绑安装期间找不到带有可执行捆绑 (Gem::GemNotFoundException) 的 gem 捆绑器 (>= 0.a)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在执行以下脚本:

gem install rdoc --no-document
gem install bundle
bundle

输出:

+ gem install rdoc --no-document
Successfully installed rdoc-6.1.1
1 gem installed
+ gem install bundle
Successfully installed bundle-0.0.1
Parsing documentation for bundle-0.0.1
Done installing documentation for bundle after 2 seconds
1 gem installed
1 gem installed
+ bundle install
/usr/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
    from /usr/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
    from /srv/myuser/.gem/ruby/2.5.0/bin/bundle:23:in `<main>'

我已将 /srv/myuser/.gem/ruby/2.5.0/bin 添加到我的路径中,以便能够安装 gem.

I've added /srv/myuser/.gem/ruby/2.5.0/bin to my path so I was able to install gems.

gem env 显示

RubyGems Environment:
  - RUBYGEMS VERSION: 2.7.7
  - RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/2.5.0
  - USER INSTALLATION DIRECTORY: /srv/myuser/.gem/ruby/2.5.0
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - SPEC CACHE DIRECTORY: /srv/myuser/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/lib/ruby/gems/2.5.0
     - /srv/myuser/.gem/ruby/2.5.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--user-install"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/bin

gem list 显示已安装的 gem.我也可以在执行时找到捆绑包:

gem list shows the installed gems. I can also find bundle when I perform:

ls -ltrah /srv/myuser/.gem/ruby/2.5.0/bin

我也尝试安装 bundler,但这也无济于事.我做错了什么?

I've also tried to install bundler but that didn't also help. What am I doing wrong?

gem which bundle 什么也没显示.gem spec bundle 正在显示.

gem which bundle is showing nothing.gem spec bundle is showing it.

更新:我尝试在运行 bundle 之前安装 bundler,但出现同样的问题:

Update: I tried to install bundler before running bundle but the same issue appears while:

宝石列表包展示

bundle (0.0.1)
bundler (2.0.1)

推荐答案

Bundler 版本 2 引入了一项新功能,可以自动使用项目的 Gemfile.lock 中指定的 Bundler 版本.因此,如果您有一个现有的 Gemfile.lock,底部有这样一行

Bundler version 2 introduced a new feature to automatically use the version of Bundler specified in the Gemfile.lock of your project. Thus, if you have an existing Gemfile.lock with a line like this at the bottom

BUNDLED WITH
   1.17.3

Bundler 将尝试使用 Bundler 版本运行 <2.0.由于您刚刚安装了 Bundler 2.0.1(和 Rubygems >= 2.7.0),因此失败并显示此相当无用的错误消息.

Bundler will try to run with a Bundler version < 2.0. Since you just have Bundler 2.0.1 (and Rubygems >= 2.7.0) installed, this fails with this rather unhelpful error message.

要解决这个问题,您可以

To fix this, you could

  • 从您的 Gemfile.lock 中删除这些行并从现在开始在任何地方使用 bundler 2.x,或者
  • 使用 gem install bundler -v '< 安装 bundler 1.x 版本2.0' 使用您的 Gemfile.lock 指定的适当版本.
  • remove the lines from your Gemfile.lock and to use bundler 2.x everywhere from now on, or
  • install a bundler 1.x version with gem install bundler -v '< 2.0' to use the appropriate version as specified by your Gemfile.lock.

有关这方面的更多信息,请参阅 Bundler 博客.

More information about this can be found on the Bundler blog.

这篇关于捆绑器:在使用 gem 进行捆绑安装期间找不到带有可执行捆绑 (Gem::GemNotFoundException) 的 gem 捆绑器 (&gt;= 0.a)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆