How to fix "Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0"

Solution 1:

I've noticed this happening when I've tried to bundle install with a fresh RVM gemset that didn't yet include bundler (as it fell back on the system bundler install which referenced the system ruby).

Running gem install bundler fixed for me.

Solution 2:

None of these worked for me, but I finally figured it out:

spring stop

I had a Rails 4 project that uses something called Spring to keep a Rails environment running in the background, for speed.

I had started Spring with Ruby 2.1.1 but then I upgraded to 2.1.2 (in Gemfile and .ruby-version). My theory is that Spring kept on running on 2.1.1 and so caused this error.

Solution 3:

Heroku Toolbelt may be causing it if you are using the heroku command, or more specifically, using bundle exec heroku, which you should never do. If you can fix your problem by removing bundle exec in front of your heroku calls, then try that first. If not, then follow what is suggested below.


Update February 25, 2017:
Heroku Toolbelt have been renamed to Heroku CLI. See these links for updated install/uninstall instructions:
https://devcenter.heroku.com/articles/heroku-cli
https://github.com/heroku/cli

Original post is provided unedited below (for legacy instructions):


If you have installed the Heroku toolbelt from the official site:

At the top of /usr/bin/heroku it probably says something like #!/usr/local/heroku/ruby/bin/ruby

Try running /usr/local/heroku/ruby/bin/ruby -v and see if it outputs ruby 1.9.3.

https://github.com/heroku/toolbelt/issues/53

› heroku --version
heroku-toolbelt/3.26.1 (x86_64-darwin10.8.0) ruby/1.9.3

Notice the 1.9.3 specified at the end there.

--- Do NOT use this page, and its packaged installer, to install the Heroku CLI on OSX:

https://toolbelt.heroku.com/

Because the technical details listed there are important:

The heroku command line client will be installed into /usr/local/heroku and /usr/local/heroku/bin will be added to your PATH.

This is detrimental, because RVM will then do this:

› rvm current
ruby-2.1.1

› heroku --version
heroku-toolbelt/3.26.1 (x86_64-darwin10.8.0) ruby/1.9.3

There is that irritating 1.9.3 version, even when I've specified another Ruby version with RVM.

Uninstall the Heroku toolbelt

There is no official uninstaller for OSX, write +1 here if you think there should be one: https://github.com/heroku/toolbelt/issues/8

Uninstall manually (moving to Trash, to keep a backup, in case something fails):

mv ~/.heroku ~/.Trash
sudo mv /usr/local/heroku ~/.Trash
sudo mv /usr/bin/heroku ~/.Trash

Install the Heroku toolbelt with homebrew instead

Because it links the current RVM version to the Heroku-toolbelt correctly. Run:

brew install heroku-toolbelt

Heroku toolbelt will then be installed only in this location:

/usr/local/Cellar/heroku-toolbelt/3.21.4

(You could also remove it easily with brew uninstall heroku-toolbelt if you wanted.)

Testing the install:

› rvm current
ruby-2.0.0-head@bloggery

› rvm list

rvm rubies

=* ruby-2.0.0-head [ x86_64 ]
   ruby-2.1-head [ x86_64 ]
   ruby-2.1.1 [ x86_64 ]

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

› rvm use ruby-2.1.1
Using /Users/Username/.rvm/gems/ruby-2.1.1

› rvm current
ruby-2.1.1

› heroku --version
heroku-toolbelt/3.26.1 (x86_64-darwin12.0) ruby/2.1.1
You have no installed plugins.

› rvm use ruby-2.0.0-head
Using /Users/Username/.rvm/gems/ruby-2.0.0-head

› heroku --version
heroku-toolbelt/3.26.1 (x86_64-darwin13.4.0) ruby/2.0.0
You have no installed plugins.

Notice it now says 2.0.0 at the end of that last command there. You now run the Heroku client with whatever rvm current ruby version you have specified in RVM.