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.
Here is the full trace:
$ 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)
How to fix this issue?
Note: I'm using OSX 10.12.6
The location to install the gems in the bundle to. This defaults to Rubygems' gem home, which is also the default location where gem install installs gems. This means that, by default, gems installed without a --path setting will show up in gem list . This setting is a remembered option.
run the command bundle install in your shell, once you have your Gemfile created. This command will look your Gemfile and install the relevant Gems on the indicated versions. The Gemfiles are installed because in your Gemfile you are pointing out the source where the gems can be downloaded from.
Common Attempts To Resolve Ruby Gem Dependencies Bundler can help to resolve dependencies when working with Ruby gems by allowing you to specify a set of gems in a Gemfile, then issue a single command to install them. Bundler then automatically resolves the dependencies for you.
Due to the update, gem install bundler will install version 2 since Jan 4, if you trying to install bundler without specifying a version. And bundler 2.0 requires rubygems version at least 3.0. First, check your rubygems installed on your local machine, using gem --version.
The only version of Bundler 100% guaranteed to work with a given Gemfile.lock file is the Bundler version that generated it. So the most reliable way to fix this error is to install that exact Bundler version.
This error is saying (in a very particular way) that RubyGems was unable to find the exact version of Bundler that is in your Gemfile.lock. This is a bug, and future Bundler & RubyGems versions will automatically install and use the exact version of Bundler your application needs to run.
Show activity on this post. Show activity on this post. Open Gemfile.lock, which is to be found in the root of your app folder. Scroll to the end of the file and see the bundler version used. Then you make sure you install the bundler version used: Or - delete the Gemfile.lock and bundle if you have higher bundler version installed.
bundler was updated from 1.7 to 2 on Jan 4. Due to the update, gem install bundler
will install version 2 since Jan 4, if you trying to install bundler without specifying a version. And bundler 2.0 requires rubygems
version at least 3.0.
First, check your rubygems installed on your local machine, using gem --version
. If you use ruby v2.5.1, your rubygems version will be or 2.7.x and under 3.x.
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.6
- RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [x86_64-darwin17]
Under rubygems version 3.x, gem install bundler
command will not work well.
To fix problem,
1) update rubygems
gem update --system
2) install an older version of bundler
gem install bundler -v 1.17.3
3) install Ruby 2.6. 2.6 was released on last Christmas, Ruby 2.6 merges bundler
gem and use rubygems
3.0.1 as default. Since Ruby 2.6, you don't need to install bundler manually.
rbenv install 2.6
Just wanted to mention, I found this just today while searching for it - and fixed it myself. Here's the key;
can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
I know nothing about any of this, I'm a hacker who gets lucky - I noticed there's a bin/bundle executable in the checked-out git repo I'm trying to work with, and tried to run it directly out of sheer desperation. The message above implied (to me) that something's executable wasn't working, not that it wasn't present (as some searches lacked the noted text, and simply couldn't find the thing) so....anyways.
[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`
Hey finally an error message that helps!
Thus, I ran gem install bundler:1.16.6
and re-ran the original command, and to my great (and hard-earned) joy, it finally worked.
I'm not 100% sure that fits as 'an answer' - don't just blindly run the command I came to, but rather consider to repeat the process to potentially reveal which issue you're having. Good luck!
EDIT for further backing: While being led to this conclusion, I also found that the bundle
command would fail wholesale - but only in the project directory - which further implied that it was something 100% project-related. I don't know what bundle is or how it works internally, but by this behavior I figured it was sub-loading scripts/executables within the git repo (similar to how git's commands can be contextual to working dirs) so filestructure examination was next. That's when the bin
folder was discovered, with an executable named bundle
- which comes full circle to above.
FWIW - someone who knows more than me regarding bundle
(I don't understand it well enough to know who to report it to, or even if this is abnormal behavior) should potentially file an issue with their github indicating that it's silently masking plaintext error messages they created to guide a user to a proper solution. Personally I'd have bin/bundle
throw an exit code indicating useful output coming to stderr
and pipe it on through...
This is how I finally solved this problem:
$ cd /path/to/my/project/
$ gem install bundler -v 1.17.3
$ bundle install
Sometimes just running bundle update --bundler
in the project directory is enough.
I am using rbenv 1.1.1 and ruby 2.5.1 and got the same error while running bundle install
. gem update --system
solved the problem
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With