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

不羁岁月 提交于 2019-12-13 03:58:49

问题


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.


回答1:


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 :) )




回答2:


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



来源:https://stackoverflow.com/questions/48435360/how-can-i-get-bundler-to-use-the-ruby-version-set-by-chruby-and-ruby-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!