Ruby-on-rails 捆绑程序:在使用 gem 进行捆绑安装期间,找不到带有可执行捆绑包 (Gem::GemNotFoundException) 的 gem 捆绑程序 (>= 0.a)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/54087856/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bundler: can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException) during bundle install with gem
提问by DenCowboy
I'm executing the following script:
我正在执行以下脚本:
gem install rdoc --no-document
gem install bundle
bundle
output:
输出:
+ 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>'
I've added /srv/myuser/.gem/ruby/2.5.0/binto my path so I was able to install gems.
我已经添加/srv/myuser/.gem/ruby/2.5.0/bin到我的路径中,所以我能够安装 gems。
the gem envshows
该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 listshows the installed gems.
I can also find bundle when I perform:
gem list显示已安装的宝石。我还可以在执行时找到捆绑包:
ls -ltrah /srv/myuser/.gem/ruby/2.5.0/bin
I've also tried to install bundler but that didn't also help. What am I doing wrong?
我也试过安装 bundler 但这也没有帮助。我究竟做错了什么?
gem which bundleis showing nothing.gem spec bundleis showing it.
gem which bundle什么也没显示。gem spec bundle正在展示它。
Update: I tried to install bundler before running bundle but the same issue appears while:
更新:我尝试在运行 bundle 之前安装 bundler,但在以下情况下出现相同的问题:
gem list bundleshows
gem list bundle显示
bundle (0.0.1)
bundler (2.0.1)
回答by Holger Just
Bundler version 2 introduced a new feature to automatically use the version of Bundler specified in the Gemfile.lockof your project. Thus, if you have an existing Gemfile.lockwith a line like this at the bottom
Bundler 版本 2 引入了一项新功能,可以自动使用Gemfile.lock项目中指定的 Bundler 版本。因此,如果您Gemfile.lock在底部有这样一条线
BUNDLED WITH
1.17.3
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.
Bundler 将尝试以低于 2.0 的 Bundler 版本运行。由于您只安装了 Bundler 2.0.1(和 Rubygems >= 2.7.0),因此失败并显示此相当无用的错误消息。
To fix this, you could
要解决此问题,您可以
- remove the lines from your
Gemfile.lockand 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 yourGemfile.lock.
Gemfile.lock从现在开始,从你的和使用 bundler 2.x 中删除行,或者- 安装 bundler 1.x 版本,
gem install bundler -v '< 2.0'以使用您的Gemfile.lock.
More information about this can be found on the Bundler blog.
可以在Bundler 博客上找到有关这方面的更多信息。
回答by Rohan
As per the description mentioned in the post , before running the below mentioned command:
根据帖子中提到的描述,在运行下面提到的命令之前:
bundle install
in the script, you need to run the below command:
在脚本中,您需要运行以下命令:
gem install bundler
So, the sequence of commands to work would be:
因此,工作的命令序列将是:
gem install bundler
bundle install
Update the bundler command if if does not work to:
如果 if 不起作用,请更新 bundler 命令:
gem install bundler -v '1.17.3'
Reason for the break in functionalities in bundler 2.0 is given in below mentioned link:
下面提到的链接给出了 bundler 2.0 中功能中断的原因:
https://bundler.io/blog/2019/01/04/an-update-on-the-bundler-2-release.html
https://bundler.io/blog/2019/01/04/an-update-on-the-bundler-2-release.html
回答by estani
I couldn't even do bundle -v. This sorted it out:
我什至做不到bundle -v。这是整理出来的:
gem update --system
Got the info from here (similar problem): find_spec_for_exe': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException)
从这里得到信息(类似问题):find_spec_for_exe': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException)
Probably some version mismatch between ruby + gem + bundler
可能是 ruby + gem + bundler 之间的版本不匹配
回答by rusllonrails
gem install bundler -v '< 2.0'
回答by Dende
I had the same problem recently. In my case I have installed a version on bundler different from what is logged in the Gemfile.lock. Please check
我最近遇到了同样的问题。就我而言,我在 bundler 上安装了一个与 Gemfile.lock 中记录的版本不同的版本。请检查
回答by Promise Preston
I faced this same issue. The issue is caused by the fact that RubyGems cannot find an executable bundle for the bundler gem on the system
我遇到了同样的问题。该问题是由于 RubyGems 在系统上找不到 bundler gem 的可执行包造成的
To fix it, first run
要修复它,首先运行
gem install bundler
gem install bundler
if you don't have bundler gem installed locally, then run
如果您没有在本地安装 bundler gem,则运行
gem update --system
gem update --system
That's all
就这样
I hope this helps
我希望这有帮助
回答by Manuel Schmitzberger
You've to install the exact version of Bundler that RubyGems is looking for by running:
您必须通过运行以下命令来安装 RubyGems 正在寻找的确切版本的 Bundler:
$ gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"
回答by Ярослав Рахматуллин
I saw a similar error message for the travis bundle after upgrading mac os to Catalina.
将 mac os 升级到 Catalina 后,我看到了 travis 包的类似错误消息。
Traceback (most recent call last):
2: from /usr/local/bin/travis:22:in `<main>'
1: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/rubygems.rb:263:in `bin_path'
/usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/rubygems.rb:284:in `find_spec_for_exe': can't find gem travis (>= 0.a) with executable travis (Gem::GemNotFoundException)
To resolve the issue, I reinstalled travis from source.
为了解决这个问题,我从源代码重新安装了 travis。
brew remove travis;
brew install -s travis
回答by boddhisattva
I just faced the same error today. The bundler version which I had installed in my system previously was: 1.16.6
我今天刚遇到同样的错误。我之前在系统中安装的 bundler 版本是:1.16.6
Followed the instructions in the official bundler docs on How to Upgrade to Bundler 2and the below two steps did the trick:
按照有关如何升级到 Bundler 2的官方捆绑器文档中的说明进行操作,以下两个步骤可以解决问题:
gem install bundler(Helps you get the latest version of bundler which as of today is 2.0.2)bundle update --bundler
gem install bundler(帮助您获得最新版本的 bundler,截至今天是 2.0.2)bundle update --bundler

