Bundler::Rubyversionmismatch: Your Ruby Version Is 1.9.3, But Your Gemfile Specified 2.0.0

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

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

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

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:

source 'https://rubygems.org'
ruby "1.9.3"

gem 'pry'

gem 'pry-nav'

# Use with command-line debugging, but not RubyMine
#gem 'debugger'

gem 'bundler'

Bundler::RubyVersionMismatch: Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0

I finally found out the solution in RVM documentation:

Pow has removed automated detection of rvm, here is how it can be
restored by creating .powenv in the root of the project, according to
Pow docs it should not be checked in to source control (unless all
team members agree on that).

These lines must be added to the .powenv file at the root of your project. Then after restarting the server everything worked like a charm!

# detect `$rvm_path`
if [ -z "${rvm_path:-}" ] && [ -x "${HOME:-}/.rvm/bin/rvm" ]
then rvm_path="${HOME:-}/.rvm"
fi
if [ -z "${rvm_path:-}" ] && [ -x "/usr/local/rvm/bin/rvm" ]
then rvm_path="/usr/local/rvm"
fi

# load environment of current project ruby
if
[ -n "${rvm_path:-}" ] &&
[ -x "${rvm_path:-}/bin/rvm" ] &&
rvm_project_environment=`"${rvm_path:-}/bin/rvm" . do rvm env --path 2>/dev/null` &&
[ -n "${rvm_project_environment:-}" ] &&
[ -s "${rvm_project_environment:-}" ]
then
echo "RVM loading: ${rvm_project_environment:-}"
\. "${rvm_project_environment:-}"
else
echo "RVM project not found at: $PWD"
fi

In RubyMine: Your Ruby version is 2.0.0, but your Gemfile specified 1.9.3 (Bundler::RubyVersionMismatch)

In RubyMine you can manage multiple SDKs, meaning ruby version and gemset.

Obviously you selected a SDK with ruby-2.0.0-p195.

The language level only defines the syntax higliting and command completion help etc. say the support of the IDE, but not the ruby version used for the project.

So you should select a different SDK (or create it first, but as you use rmv and RubyMine knows rmv, you should see all your SDKs)

If ruby-1.9.3 is your system default, you might install the same version again with rvm to make it available for RubyMine

rvm install ruby-1.9.3

and then select it in RubyMine.

Why do I get the error Your Ruby version is 2.0.0, but your Gemfile specified 2.2.2 although I have 2.2.2 installed

I finally solved my problem using this thread Bundler not working with rbenv, could not find [gem],

by using these commands after reinstalling rbenv:

  • gem install --no-ri --no-rdoc bundler
  • rbenv rehash
  • bundle --path=vendor/bundle

Your Ruby version is 2.0.0, but your Gemfile specified 2.1.0

Run

gem install bundler

or

gem update bundler 

which may fix your problem.

For all new installed versions of Ruby you should update or install a new bundler.



Related Topics



Leave a reply



Submit