How to Bundle Install Gemfile with Specific Version of Bundler

How to `bundle install` when your Gemfile requires an older version of bundler?

First you need to install the appropriate version of bundler:

% gem install bundler -v '~> 1.0.0'
Successfully installed bundler-1.0.22

Then force rubygems to use the version you want (see this post):

% bundle _1.0.22_ install

Bundler : Is there a way to set the version?

You need to delete manually the directory on your problematic ruby version: for example if there is a bundler problem with the 2.5.1 ruby version, go to this path:

/Users/YOUR_USER/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/

and delete the bundler directory.

If bundler is in the default specification you also need to remove the bundler associated file on this path:

/Users/YOUR_USER/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/specifications/default

Then you can re-install a specific version of bundler using @Unixmonkey answer

Fix Your Ruby version is 2.6.8, but your gemfile specified 2.5.5

Finally got it working.

So the key to the problem as well to the solution was the fact that which bundle gave:

/usr/local/bin/bundle

while which ruby gave:

/Users/Mahmoud/.rbenv/shims/ruby

indicating that bundle isn't using ruby from rbenv.

I already had the path set in ~/.bash_profile:

export PATH="$HOME/.rbenv/shims:$PATH"
eval "$(rbenv init -)"

but apparently this was not enough as I was using zsh. Had to add those same 2 lines to ~/.zshrc as well and restarted terminal. Now bundle install is working as expected.

After updating ~/.zshrc which bundle gives:

/Users/Mahmoud/.rbenv/shims/bundle

indicating that the problem was just that bundle was using the wrong ruby.

So if you have this problem, just make sure ~/.bash_profile and ~/.zshrc have the correct path by adding the 2 lines indicated above. Restart terminal and check if its working now.



Related Topics



Leave a reply



Submit