I created a Ruby project, but when running bundle update
and bundle install
it returns an error:
Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0
An image of it is: http://i.imgur.com/dZMhI11.png?1
My gemfile is:
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.0'
group :development do
gem 'sqlite3', '1.3.8'
end
gem 'sass-rails', '4.0.0'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.0'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
If you run
ruby -v
you're going to see that you've installed Ruby 1.9.3, but the first line in your Gemfile specifies that you want to use Ruby 2.0.0.You should either install Ruby 2.0.0 or change the first line in your Gemfile to specify Ruby 1.9.3.
sample of Gemfile:
In my case I used
rvm get head
to update the RVM version and it worked.Heroku Toolbelt may be causing it if you are using the
heroku
command, or more specifically, usingbundle exec heroku
, which you should never do. If you can fix your problem by removingbundle exec
in front of yourheroku
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
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:
This is detrimental, because RVM will then do this:
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):
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:
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.If you are using a Ruby version manager like RVM or rbenv, then create, in the top-level directory of your project, a file named
.ruby-version
containing the version spec'd in your Gemfile, e.g.:That apparently is the cross-
{rbenv,rvm}
way of spec'ing the version now.I discovered my rake or rails script under the bin directory was using another version of ruby. I compared two rake scripts from two servers (production and development) and it showed me they were using different ruby versions. So I had to update accordingly.
ruby-switch was removed from ubuntu 14.04 and up. I'll leave this answer for posterity, but you probably need a different solution. Check out "Install ruby 2.0 without ruby-switch?" as well.
If you have you've installed a new version of Ruby but are still getting errors about the Gemfile mismatch, you probably need to use
ruby-switch
to set the new version of Ruby as your default: