rubybundlerchruby

How can I get bundler to use the Ruby version set by chruby and .ruby-version?


I have the pleasure of setting up a development environment for an application running Ruby 1.8.7. Unfortunately bundler is not using the version of Ruby set in .ruby-version by chruby.

Also, I have ruby "1.8.7" included in the Gemfile

Whereas the local version is ruby-1.8.7-p374, the bundler environment is using ruby-2.5.0p0.

$ ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin17.3.0]

$ bundle env | grep Ruby
Ruby          2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]

This results in the following message:

$ bundler
Your Ruby version is 2.5.0, but your Gemfile specified 1.8.7

This issue contains some helpful comments but so far I haven't been able to resolve the issue. I do have Ruby 2.5.0 installed in /usr/local/opt as a result of installing vim via brew install vim. This would appear to the version that the Ruby 1.8.7 bundle script is using, as evidenced by:

$ which bundle
/Users/keithpitty/.gem/ruby/1.8.7/bin/bundle

$ head -n1 $(which bundle)
#!/usr/local/opt/ruby/bin/ruby

This problem is proving to be quite frustrating. I would very much appreciate any suggestions.


Solution

  • I fixed this by installing RubyGems 1.6.2. See How to set correct Ruby version in gem environment for more.