131

When I try to do bundler update I get this error:

.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in
`to_specs': Could not find bundler (>= 0) amongst
[rake-0.8.7, rake-0.8.7, rubygems-update-1.8.4] (Gem::LoadError)

I'm new to Ruby, can someone tell me what would cause this? Rake 0.8.7 is installed.

Promise Preston
  • 24,334
  • 12
  • 145
  • 143
Steven
  • 4,826
  • 3
  • 35
  • 44

17 Answers17

227

Make sure you're entering "bundle" update, if you have the bundler gem installed.

bundle update

If you don't have bundler installed, do gem install bundler.

ardavis
  • 9,842
  • 12
  • 58
  • 112
70

I had this problem, then I did:

gem install bundler

then in your project folder do:

bundle install

and then you can run your project using:

bundle exec rails server
Dorian
  • 1,079
  • 11
  • 19
  • gem install bundle -- this did it for me as well. – Don Cote May 21 '13 at 03:02
  • 13
    Notice that the "bundle" gem is simply a gem that declares "bundler" as a dependency, which essentially fixes your typo. https://github.com/will/bundle/blob/285ddcba7c2d0742e50b068c3fe47eeaa98e309b/bundle.gemspec#L10 – sealocal Aug 05 '16 at 16:34
14

I had the same problem. This worked for me:

  1. run rvm/script/rvm and also add it to your .profile or .bash_profile as shown in https://rvm.io/rvm/install/

  2. use bundle without sudo

mpapis
  • 52,729
  • 14
  • 121
  • 158
bjelli
  • 9,752
  • 4
  • 35
  • 50
11

If You are using rvm, then try the following command:

rvmsudo gem install bundler

According to another question: Could not find rails (>= 0) amongst [] (Gem::LoadError)

Hope it helped, Cheers

Andre Figueiredo
  • 12,930
  • 8
  • 48
  • 74
Andrew Khouzam
  • 171
  • 2
  • 3
8

The command is bundle update (there is no "r" in the "bundle").

To check if bundler is installed do : gem list bundler or even which bundle and the command will list either the bundler version or the path to it. If nothing is shown, then install bundler by typing gem install bundler.

Zabba
  • 64,285
  • 47
  • 179
  • 207
8

I had the same problem .. something happened to my bash profile that wasn't setting up the RVM stuff correctly.

Make sure your bash profile has the following line:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.

Then I ran "source ~/.bash_profile" and that reloaded everything that was in my bash profile.

That seemed to fix it for me.

alex
  • 479,566
  • 201
  • 878
  • 984
Brian Vitrue
  • 101
  • 1
  • 2
  • Thanks for this. While I knew how to spell "bundle" vs "bundler", I'd completely forgotten that I reinstalled zsh and in the process accidentally blew this line away from my .zshrc. Had been pulling my hair out over this for a while :) – rmurphey Aug 27 '12 at 14:31
  • This answer is old but for me has been the solution! – jonnyjava.net Oct 01 '16 at 21:53
  • Make sure this is the LAST line in your profile file – rmcsharry Oct 08 '18 at 20:23
6

According to this answer to a similar question, it should be enough:

rvmsudo gem install bundler.

Cheers

Community
  • 1
  • 1
Andrew Khouzam
  • 171
  • 2
  • 3
6

If you're using rbenv running rbenv rehash can solve this after you've installed bundler and are still getting the issue.

eebbesen
  • 5,070
  • 8
  • 48
  • 70
4

You may have to do something like "rvm use 1.9.2" first so that you are using the correct ruby and gemset. You can check which ruby you are using by doing "which ruby"

mgauthier
  • 321
  • 2
  • 6
4

I had this same concern when setup a new Bundler gem version (2.2.11) on my machine.

I was getting the error below:

/home/username/.rbenv/versions/2.7.2/lib/ruby/2.7.0/rubygems.rb:277:in `find_spec_for_exe': Could not find 'bundler' (2.2.11) required by your /home/username/Projects/my_project/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.2.11`
        17: from /home/username/.rbenv/versions/2.7.2/bin/rspec:23:in `<main>'
        16: from /home/username/.rbenv/versions/2.7.2/bin/rspec:23:in `load'
        15: from /home/username/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rspec-core-3.10.1/exe/rspec:4:in `<top (required)>'
        14: from /home/username/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rspec-core-3.10.1/lib/rspec/core/runner.rb:45:in `invoke'

Here's how I achieved it:

First, I had already installed the Bundler gem 2.2.11 and made it the default gem:

gem install --default bundler -v 2.2.11

Next, I listed my Bundler versions:

gem list bundler

Finally, I updated my gems to use the newly installed Bundler:

gem update --system

That's all.

I hope this helps

Promise Preston
  • 24,334
  • 12
  • 145
  • 143
2

I got this after upgrading to ruby 2.1.0. My PATH was set in my login script to include .gem/ruby/2.0.0/bin. Updating the version number fixed it.

Thomas Leonard
  • 7,068
  • 2
  • 36
  • 40
2

The system might be running "rootless". Try to set the firmware nvram variable boot-args to "rootless=0". Try to run set of commands:

sudo nvram boot-args="rootless=0"; 
sudo reboot

After reboot completes, run:

sudo gem install bundler
Bogdan Ustyak
  • 5,639
  • 2
  • 21
  • 16
1

Can be related to https://github.com/bundler/bundler-features/issues/34 if you are running the command inside another bundle exec. Try using Bundler.with_original_env if that is the case.

brauliobo
  • 5,843
  • 4
  • 29
  • 34
1

For anyone encountering this issue with Capistrano: capistrano isn't able to locate the bundler. The reason might be that you installed bundler under some other gemset where the Capistrano isn't even looking.

  1. List your gemsets.

rvm gemset list

  1. Use a particular gemset.

rvm use 'my_get_set'

  1. Install bundler under that gemset.

gem install bundler

Then, try again with the deploy task.

Nerve
  • 6,463
  • 4
  • 29
  • 29
1

I resolved it by deleting Gemfile.lock and gem install bundler:2.2.0

0

In my case I believe I had an old Ruby remaining on the system, not registered on rvm, and even if the path variables and gem list was okay, it would still use the old Ruby during deployments with Capistrano

And then I realized, the Ruby I had installed with rvm wasn't set to the default one. Running

rvm alias create default <rvm_registered_ruby>

Fixed it.

Cyril Duchon-Doris
  • 12,964
  • 9
  • 77
  • 164
0

Just in case, I had similar error with bundler 2.1.2 and solved it with:

sudo gem install bundler -v 1.17.3

If you have several bundler versions installed, then you can run specific version of bundle this way: bundle _1.17.3_ exec rspec

Though seems like later bundler versions are pretty buggy (had issues on 3 different projects on 2 operation systems), having one old bundler may work the best, at least this is what I have on my Ubuntu & MacOS

Latest bundler versions may override stable bundler -v 1.17.3. It can be not easy to remove latest bundler from system, here is what helped me:

  • Remove default version from gem env gempath: https://stackoverflow.com/a/60550744/1751321
  • Remove rm bundler.rb && rm -rf bundler folder from load paths: ruby -e 'puts $LOAD_PATH'
  • Then reinstall stable gem install bundler -v 1.17.3 (Not sudo! it is important)

Script ruby fix_bundler.rb

require 'fileutils'

load_paths = `ruby -e 'puts $LOAD_PATH'`
load_paths.split.each do |path|
  target = File.join path, "bundler.rb"
  if File.exist? target
    puts "Deleting #{target}"
    File.delete target
  end

  target = File.join path, "bundler"
  if File.directory? target
    puts "Deleting #{target}"
    FileUtils.rm_rf target
  end
  
end

Gem.paths.path.each do |path|
  path_mask = File.join path, "specifications", "default", "bundler*"
  Dir[path_mask].each do |target|
    puts "Deleting #{target}"
    FileUtils.rm_rf target
  end  
end

puts "✅ bundler fixed"
Daniel Garmoshka
  • 5,849
  • 39
  • 40