rbenv: 'find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
I’m new to rbenv (was using RVM for long time). Today I do clean uninstall of my RVM and install rbenv. I managed to install Ruby 2.5.1 without any issues.
But when I try to run bundle install
for a project today, I got the following error:
'find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
Seems like something is broken with my bundler installation but I’m not sure what is wrong. Running gem install bundler
with sudo
doesn’t solve the problem. I tried running rbenv rehash
as well but it didn’t work.
Here is the full trace:
$ echo $SHELL
/bin/zsh
$ which rvm
rvm not found
$ rbenv --version
rbenv 1.1.1
$ 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)
How to fix this issue?
Note: I’m using OSX 10.12.6
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 13
- Comments: 19 (3 by maintainers)
Commits related to this issue
- Update gem to 2.7.9 New bundler doesn't work with old gem: https://github.com/rbenv/rbenv/issues/1138 — committed to TeBoring/protobuf by TeBoring 5 years ago
- Update gem to 2.7.9 (#6265) New bundler doesn't work with old gem: https://github.com/rbenv/rbenv/issues/1138 — committed to protocolbuffers/protobuf by TeBoring 5 years ago
- Bundler version set ref. https://github.com/rbenv/rbenv/issues/1138 — committed to travis-ci/travis-migrations by JaroslawSokol 5 years ago
- Fix Travis Travis is using an older version of Ruby Gems which started having trouble installing Bundler. See rbenv/rbenv#1138 — committed to sass/dart-sass by nex3 5 years ago
- Fix Travis Travis is using an older version of Ruby Gems which started having trouble installing Bundler. See rbenv/rbenv#1138 — committed to sass/dart-sass by nex3 5 years ago
- Fix Travis (#809) Travis is using an older version of Ruby Gems which started having trouble installing Bundler. See rbenv/rbenv#1138 — committed to sass/dart-sass by nex3 5 years ago
Can you try with
gem i bundler -v 1.17.3
andbundle i
on your project directory?@zulhfreelancer @hsbt anwser here: https://bundler.io/blog/2019/01/04/an-update-on-the-bundler-2-release.html
Check the bundler version on Gemfile.lock
cat Gemfile.lock | grep -A 1 "BUNDLED"
That will give bundler version, something like thisBUNDLED WITH 2.0.1
Then install that specific version of bundlergem install bundler -v '2.0.1'
Thanks @montdidier - it should be
update
notupgrade
:gem update --system '2.7.9'
The issue is that RubyGems cannot find an executable bundle for the bundler gem on the system
To fix it, first run
gem install bundler
if you don’t have bundler version 2 installed locally, then run
gem update --system
That’s all
I hope this helps
I tried all the methods and it didn’t work. So I deleted Gemfile.lock and then execute
bundle install
, I compare Gemfile.lock via gitdiff,As @gsum said,Gemfile.lock existBUNDLED WITH 2.0.1
, just install the correspondingbundle
version.gem update --system '2.7.9'
fixes my issue.Probably the correct answer should be to upgrade ruby gems
gem upgrade --system '2.7.9'
at a bare minimum as the addresses a number of CVE also. Bundler 2.0.1 will magically worked after that too.https://blog.rubygems.org/2019/03/05/2.7.9-released.html
Thank you!
See https://bundler.io/blog/2019/05/14/solutions-for-cant-find-gem-bundler-with-executable-bundle.html
Works for me, thank you!! @hsbt
MacOS 10.14.4 should use
gem update --system '3.0'
andbundle i