How to fix "Your Ruby version is 2.3.0, but your Gemfile specified 2.2.5" while server starting

Ruby on-RailsRubyRubygems

Ruby on-Rails Problem Overview


I am getting this error while running server, how do I fix this?

enter image description here

Ruby on-Rails Solutions


Solution 1 - Ruby on-Rails

You better install Ruby 2.2.5 for compatibility. The Ruby version in your local machine is different from the one declared in Gemfile.

If you're using rvm:

rvm install 2.2.5
rvm use 2.2.5

else if you're using rbenv:

rbenv install 2.2.5
rbenv local 2.2.5

else if you can not change ruby version by rbenv, read here

Solution 2 - Ruby on-Rails

If you have already installed 2.2.5 and set as current ruby version, but still showing the same error even if the Ruby version 2.3.0 is not even installed, then just install the bundler.

gem install bundler

and then:

bundle install

Solution 3 - Ruby on-Rails

If you are using rbenv then make sure that you run the "rbenv rehash" command after you set local or global ruby version. It solved the issue for me.

rbenv rehash

Solution 4 - Ruby on-Rails

Your Gemfile has a line reading

ruby '2.2.5'

Change it to

ruby '2.3.0'

Then run

bundle install

Solution 5 - Ruby on-Rails

A problem I had on my Mac using rbenv was that when I first set it up, it loaded a bunch of ruby executables in /usr/local/bin - these executables loaded the system ruby, rather than the current version.

If you run

which bundle

And it shows /usr/local/bin/bundle you may have this issue.

Search through /usr/local/bin and delete any files that start with #!/user/bin ruby

Then run

rbenv rehash

Solution 6 - Ruby on-Rails

Two steps worked for me:

gem install bundler

bundle install --redownload # Forces a redownload of all gems on the gemfile, assigning them to the new bundler

Solution 7 - Ruby on-Rails

it can also be in your capistrano config (Capfile):

set :rbenv_ruby, "2.7.1"

Solution 8 - Ruby on-Rails

Add the following to your Gemfile

ruby '2.3.0'

Solution 9 - Ruby on-Rails

I had this problem but I solved it by installing the version of the ruby that is specified in my gem file using the RVM

    rvm install (ruby version)

After the installation, I use the following command to use the the version that you installed.

    rvm --default use (ruby version)

You have to install bundler by using the following command in order to use the latest version

    gem install bundler 

After the above steps, you can now run following command to install the gems specified on the gemfile

    bundle install

Solution 10 - Ruby on-Rails

Had same issue. I'm using rbenv and which ruby would show the rbenv version:

/Users/Mahmoud/.rbenv/shims/ruby

which bundle though would show:

/usr/local/bin/bundle

After looking in every possible place, turns out my problem was that I needed to update path in ~/.zshrc in addition to ~/.bash_profile (where I originally had the changes)

if you're running zsh add those two lines in ~/.zshrc (or the equivalent file) in addition to ~/.bash_profile

export PATH="$HOME/.rbenv/shims:$PATH"
eval "$(rbenv init -)"

After saving, quit terminal and relaunch before retrying. Hopefully this would help.

Solution 11 - Ruby on-Rails

I am on Mac OS Sierra. I had to update /etc/paths and add /Users/my.username/.rbenv/shims to the top of the list.

Solution 12 - Ruby on-Rails

For $ Your Ruby version is 2.3.0, but your Gemfile specified 2.4.1. Changed 2.4.1 in Gemfile to 2.3.0

Solution 13 - Ruby on-Rails

If you have some dependency on the version of the Ruby , then install the appropriate version. otherwise change the version in the gemfile in the current directory.

rbenv install <required version>
rbenv local <required version>

Even after installation it was showing the same error for me, so I just restart the mac, then do the bundle install, it works :)

it should show something like this

   <user>@<repo>% rbenv versions 
      system
    * 2.3.7 (set by <app>)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionunknownView Question on Stackoverflow
Solution 1 - Ruby on-RailsTan NguyenView Answer on Stackoverflow
Solution 2 - Ruby on-RailsTariqueView Answer on Stackoverflow
Solution 3 - Ruby on-RailskahcvView Answer on Stackoverflow
Solution 4 - Ruby on-RailsEd de AlmeidaView Answer on Stackoverflow
Solution 5 - Ruby on-RailsMikeView Answer on Stackoverflow
Solution 6 - Ruby on-RailsKaka RutoView Answer on Stackoverflow
Solution 7 - Ruby on-RailsDorianView Answer on Stackoverflow
Solution 8 - Ruby on-RailsblncView Answer on Stackoverflow
Solution 9 - Ruby on-RailsSantino M. Malong A.View Answer on Stackoverflow
Solution 10 - Ruby on-RailsmratebView Answer on Stackoverflow
Solution 11 - Ruby on-Railsvilly393View Answer on Stackoverflow
Solution 12 - Ruby on-RailsArushi SinghalView Answer on Stackoverflow
Solution 13 - Ruby on-Railsarpit1714View Answer on Stackoverflow