Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bundler: can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException) during bundle install with gem

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/bin to my path so I was able to install gems.

the gem env shows

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 shows the installed gems. I can also find bundle when I perform:

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?

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

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

gem list bundle shows

bundle (0.0.1) bundler (2.0.1) 
like image 404
DenCowboy Avatar asked Jan 08 '19 08:01

DenCowboy


People also ask

Where are bundler gems installed?

In addition, the user deploying the application may not have permission to install gems to the system, or the web server may not have permission to read them. As a result, bundle install --deployment installs gems to the vendor/bundle directory in the application. This may be overridden using the --path option.

How do I update my bundler to latest version?

Bundler will never change your application to a new major version until you choose to do so. If your application is ready, you can upgrade that application to the latest installed version of Bundler by running bundle update --bundler . We recommend committing your Gemfile. lock before you upgrade.


1 Answers

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 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

  • 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.

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

like image 127
Holger Just Avatar answered Oct 11 '22 20:10

Holger Just