1

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.

Keith Pitty
  • 1,498
  • 1
  • 12
  • 22

3 Answers3

0

Have you mentioned the ruby version in Gemfile you are planning to use, if not trying adding the ruby version in your Gemfile, more info here.

ruby '~> 2.3.0'

Also on a side note, if you have multiple ruby versions in you machine, ideally you can make use RVM or rbenv to manage multiple Ruby versions. ( makes your life easy :) )

sghosh968
  • 591
  • 6
  • 12
  • Yes, as already noted, I have specified `ruby "1.8.7"` in the Gemfile and I use `chruby` rather than `rvm` or `rbenv` to manage multiple Ruby versions. – Keith Pitty Jan 25 '18 at 05:16
0

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

Keith Pitty
  • 1,498
  • 1
  • 12
  • 22
0

I followed these instructions https://gist.github.com/andrewroycarter/6815905

In short, I have a project using 2.5.8 and my local version is 2.7.2, so bundle install says

Your Ruby version is 2.7.2, but your Gemfile specified 2.5.8

What I did was to go to my home directory (or at least leave the project directory), activate chruby 2.5.8 and install the bundle gem

cd
chruby 2.5.8
gem install bundler

Now, when I go back to the project directory I can do bundle install.

Teitur
  • 163
  • 1
  • 7