“Your Ruby version is 1.9.3, but your Gemfile spec

2019-07-02 07:14发布

RVM won't let me run bundle because it thinks my Ruby version is different from what my Gemfile says, but it isn't:

$ rvm list

rvm rubies

=> ruby-1.9.3-p194 [ x86_64 ]
   ruby-1.9.3-p429 [ x86_64 ]
 * ruby-2.0.0-p195 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin13.0.0]

Gemfile:

ruby '1.9.3-p194'

But then:

$ bundle install
Your Ruby version is 1.9.3, but your Gemfile specified 1.9.3-p194
$ 

This seems like a very strange thing. Any ideas? There are a lot of people who have this question, but their Gemfiles are obviously different from the running version. I've even done rvm use 1.9.3-p194 and then immediately after bundle install but I get the same error. bundle update produces the same error.

If I remove the ruby version from the Gemfile, it will default to 2.0.0 but switching by rvm use to the proper version (to comply with remote server ruby version) actually works. Running bundle install then works.

Could this error come from also having an rvmrc file (even though specifies the same ruby version) in the Rails project as well?

2条回答
成全新的幸福
2楼-- · 2019-07-02 07:48

Remove the line and add a file named '.ruby-version' with '1.9.3-p194' in it. The .ruby-version approach is compatible with several ruby managers beyond rvm.

查看更多
何必那么认真
3楼-- · 2019-07-02 07:54

The ruby directive explicitly leaves out the ability to specify a patch level. Ruby patches often include important bug and security fixes and are extremely compatible. http://bundler.io/v1.2/gemfile_ruby.html

The entry in your Gemfile should simply be ruby '1.9.3'

查看更多
登录 后发表回答