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
Have a Parent Class's Method Access the Subclass's Constants
Breaking a Large Rails App into Smaller Apps
How to Find Out the Starting Point for Each Match in Ruby
Raise Exception on Shell Command Failure
"Ruby.Exe Is Not Recognized as an Internal or External Command" in Windows 7
In Depth Ruby Gem Development Resources (Book, Video, Sites)
How to Create a Folder (If Not Present) with Logger.New
"No Available Formula for Gcc46" While Installing Ruby 1.9.3 on Os X with Rvm:
Package Configuration for Libffi Is Not Found in MACos While Installing Travis-Cli
Single Custom Param Name in Routes for Nested Resources Rails 4.1
Setting the Environment in Gemfile for Bundling Install/Update Based on a Customize File
How to Assert That No Route Matches in a Rails Integration Test