我是rbenv的新手(长时间使用RVM)。今天,我确实卸载RVM并安装rbenv。我设法安装了Ruby 2.5.1,没有任何问题。
但是当我今天尝试为项目运行bundle install
时,出现以下错误:
'find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
我的捆绑器安装似乎损坏了某些东西,但是我不确定出什么问题。将gem install bundler
与sudo
一起运行不能解决问题。
这是完整的跟踪记录:
$ echo $SHELL
/bin/zsh
$ cat ~/.gemrc
gem: --no-document
install: --no-document
update: --no-document
$ rbenv versions
system
* 2.5.1 (set by /Users/zulh/.rbenv/version)
$ ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
$ which ruby
/Users/zulh/.rbenv/shims/ruby
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.6
- RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [x86_64-darwin16]
- INSTALLATION DIRECTORY: /Users/zulh/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0
- USER INSTALLATION DIRECTORY: /Users/zulh/.gem/ruby/2.5.0
- RUBY EXECUTABLE: /Users/zulh/.rbenv/versions/2.5.1/bin/ruby
- EXECUTABLE DIRECTORY: /Users/zulh/.rbenv/versions/2.5.1/bin
- SPEC CACHE DIRECTORY: /Users/zulh/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/zulh/.rbenv/versions/2.5.1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-16
- GEM PATHS:
- /Users/zulh/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0
- /Users/zulh/.gem/ruby/2.5.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-document"
- "install" => "--no-document"
- "update" => "--no-document"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/zulh/.rbenv/versions/2.5.1/bin
- /usr/local/Cellar/rbenv/1.1.1/libexec
- /Users/zulh/.rbenv/shims
- /usr/local/bin
- /Users/zulh/go/bin
- /usr/local/bin
- /Users/zulh/go/bin
- /Users/zulh/.rbenv/shims
- /usr/local/bin
- /Users/zulh/go/bin
- /Users/zulh/.rbenv/shims
- /usr/local/bin
- /Users/zulh/go/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Library/Frameworks/Mono.framework/Versions/Current/Commands
- /Applications/Postgres.app/Contents/Versions/latest/bin
- /Users/zulh/projects/tifig/build/tifig
- /Applications/Postgres.app/Contents/Versions/latest/bin
- /Users/zulh/projects/tifig/build/tifig
- /Applications/Postgres.app/Contents/Versions/latest/bin
- /Users/zulh/projects/tifig/build/tifig
- /Applications/Postgres.app/Contents/Versions/latest/bin
- /Users/zulh/projects/tifig/build/tifig
- /Applications/Postgres.app/Contents/Versions/latest/bin
$ which bundler
/Users/zulh/.rbenv/shims/bundler
$ bundler --version
Traceback (most recent call last):
2: from /Users/zulh/.rbenv/versions/2.5.1/bin/bundler:23:in `<main>'
1: from /Users/zulh/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/Users/zulh/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundler (Gem::GemNotFoundException)
$ cd projects/www.ruby-lang.org
$ bundle install --without production
Traceback (most recent call last):
2: from /Users/zulh/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>'
1: from /Users/zulh/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/Users/zulh/.rbenv/versions/2.5.1/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)
$ sudo gem install bundler
Password:
Successfully installed bundler-2.0.1
1 gem installed
$ which bundler
/Users/zulh/.rbenv/shims/bundler
$ bundler --version
Traceback (most recent call last):
2: from /Users/zulh/.rbenv/versions/2.5.1/bin/bundler:23:in `<main>'
1: from /Users/zulh/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/Users/zulh/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundler (Gem::GemNotFoundException)
$ bundle install --without production
Traceback (most recent call last):
2: from /Users/zulh/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>'
1: from /Users/zulh/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/Users/zulh/.rbenv/versions/2.5.1/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)
如何解决此问题?
注意:我正在使用OSX 10.12.6
答案 0 :(得分:47)
bundler was updated from 1.7 to 2 on Jan 4。由于此更新,如果您尝试安装捆绑程序而未指定版本,那么gem install bundler
将自1月4日开始安装版本2。捆绑软件2.0至少需要rubygems
版本3.0。
首先,使用gem --version
检查安装在本地计算机上的rubygems。如果您使用ruby v2.5.1,则您的rubygems版本将为或2.7.x且低于3.x。
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.6
- RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [x86_64-darwin17]
在rubygems 3.x版下,gem install bundler
命令无法正常工作。
要解决问题,
1)更新红宝石
gem update --system
2)安装旧版本的bundler
gem install bundler -v 1.17.3
3)安装Ruby 2.6。 2.6于去年圣诞节Ruby 2.6 merges bundler
gem and use rubygems
3.0.1 as default发布。从Ruby 2.6开始,您无需手动安装捆绑程序。
rbenv install 2.6
答案 1 :(得分:5)
只想提一下,我是在今天搜索时发现的-并自行修复。这是钥匙;
找不到宝石捆绑包(> = 0.a)具有可执行捆绑包(Gem :: GemNotFoundException)
我对此一无所知,我是一个很幸运的黑客-我注意到我正在尝试使用的已签出git repo中有一个bin / bundle可执行文件,并试图直接运行它绝望上面的消息(对我而言)暗示某件可执行文件不起作用,而不是不存在(因为某些搜索缺少所标注的文本,而根本无法找到该东西)。 ...无论如何。
[rndusr@monster live]$ bin/bundle
Traceback (most recent call last):
2: from bin/bundle:3:in `<main>'
1: from /home/rndusr/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems.rb:263:in `bin_path'
/home/rndusr/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': Could not find 'bundler' (1.16.6) required by your /usr/src/git/redacted/live/Gemfile.lock. (Gem::GemNotFoundException)
To update to the lastest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:1.16.6`
嘿,最后一条错误消息对您有所帮助!
因此,我运行了gem install bundler:1.16.6
并重新运行了原始命令,令我非常高兴(来之不易)高兴的是,它终于奏效了。
我不确定100%是否适合作为“答案”-不要盲目运行我所遇到的命令,而应考虑重复此过程以潜在地揭示您遇到的问题。祝你好运!
编辑以得到进一步的支持:虽然得出了这个结论,但我还发现bundle
命令将批发失败-但仅在项目目录中-这进一步暗示了与项目100%相关的东西。我不知道什么是bundle或它在内部如何工作,但是通过这种行为,我发现它是在git repo中子加载脚本/可执行文件(类似于git的命令如何与工作目录相关联),因此接下来是文件结构检查。那时发现了bin
文件夹,其中包含一个名为bundle
的可执行文件-上面有一个完整的圆圈。
FWIW-对bundle
的了解比我更多的人(我不太了解该向谁报告,甚至是不正常的举报),应该向他们的github提出问题表示它正在默默地掩盖他们创建的纯文本错误消息,以指导用户找到适当的解决方案。就我个人而言,我会抛出bin/bundle
的退出代码,指示有用的输出进入stderr
并将其通过...传递给
答案 2 :(得分:4)
这就是我最终解决此问题的方法:
$ cd /path/to/my/project/
$ gem install bundler -v 1.17.3
$ bundle install
答案 3 :(得分:0)
我正在使用rbenv 1.1.1和ruby 2.5.1,在运行bundle install
时遇到了相同的错误。 gem update --system
解决了问题
答案 4 :(得分:0)
我删除了Gemfile.lock
,此后一切正常。
答案 5 :(得分:0)
有时仅在项目目录中运行bundle update --bundler
即可。