bundle uses wrong ruby version

17,324

Solution 1

Running the command below helped me somehow: rbenv exec gem install bundler

Solution 2

Assumption: You are using RVM. This means there's a ruby version installed outside of RVM. Clear your rvm rubies by running

rvm uninstall <ruby version>

once you have uninstalled all rvm rubies do ruby -v, if this returns an output specifying a ruby version then thats the root of the problem. Uninstall it with

sudo apt-get remove ruby

Now install your rvm rubies with rvm install <ruby version> and set it as default rvm use <ruby version>

Now install bundler

gem install bundler

And do bundle install

Share:
17,324
Linus
Author by

Linus

Updated on June 11, 2022

Comments

  • Linus
    Linus almost 2 years

    I'm trying to run

    env RAILS_ENV=test bundle exec rake db:migrate

    and get the following error

    Your Ruby version is 2.1.7, but your Gemfile specified 2.2.3

    ruby -v

    gives me

    ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]

    I'm using rbenv, if that matters. rbenv versions gives the following: system * 2.2.3 (set by /Users/thatsme/Projects/demoproject/.ruby-version) So I have no ruby 2.1.7 installed. Spring is not running and I've run rbenv rehash. Then bundler gem is installed. I'm going nuts on this. Can somebody please tell me why the wrong ruby version is being used? Thanks!