bilal
bilal

Reputation: 79

Your Ruby version is 2.6.0, but your Gemfile specified 2.5.0

Having trouble doing bundle. My project is using 2.5.0 but every time i do ruby -v it gives me ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin18]

I am using rbenv and my rbenv local is 2.5.0 and rbenv global is 2.5.0

Every time I do Bundle gives me an error Your Ruby version is 2.6.0, but your Gemfile specified 2.5.0

I have tried gem install bundler but it doesn't solves the problem.

source 'http://rubygems.org'

ruby '2.5.0'
gem 'rails', '5.0'

and my .ruby-version is also 2.5.0

Upvotes: 3

Views: 19606

Answers (6)

Sir'Damilare
Sir'Damilare

Reputation: 314

I tried rbenv, and rvm and Nothing worked for me (I am using mac M1 chip. shell is Zsh).

But asdf worked eventually.

  1. I installed asdf using brew install asdf
  2. Added it to PATH with the following cd ~ then nano .zshrc, type or paste export PATH="$HOME/.asdf/shims:$PATH" and save it to file by pressing ctrl + X and then press Y on your keyboard followed by enter
  3. proceed to download ruby plugin for asdf using asdf plugin add ruby
  4. then proceeded to download the ruby that is prompted in my error msg, 2.6.10 using asdf install ruby 2.6.10
  5. set global ruby to 2.6.10 using asdf global ruby 2.6.10 (change 'global' to 'local' if you only intend to set it locally)
  6. Close the terminal and re-launch it
  7. To check for the active ruby, I did asdf current ruby gave me 2.6.10
  8. ruby -v also gave me 2.6.10. Please note that this is the first time it gave me that, so far, it had given me entirely something else even after 48hours of troubleshooting using rbenv and rvm

By now, the error message should be cleared. But if it persists (Which shouldn't). then create a .tool-versions file in your project root that contains the text of the ruby version we just installed eg ruby 2.6.10

I hope this helps someone on the other end of the internet Good luck. PS, i uninstalled my rbenv

Upvotes: 0

Heath Falkenrath
Heath Falkenrath

Reputation: 1

If you are using VS Code, in the Gemfile you have a specified version of Ruby that you can change. I just ran into this issue and once I changed the version to my current version of Ruby, it fixed it. Hope this helps anyone with same issue.

Upvotes: -1

Babatunde Mustapha
Babatunde Mustapha

Reputation: 2653

if you are using zsh, open your .zshrc by running

nano ~/.zshrc

then add these lines to the file

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

then run

source ~/.zshrc

Upvotes: 0

Eduardo Sztokbant
Eduardo Sztokbant

Reputation: 792

I'm using macOS and managed to solve this problem by using rvm first to install the desired ruby version (2.5.7 in my case).

Step-by-step:

  • Install rvm from rvm.io - rvm version may be udpated with:
rvm get head
  • Add rvm to your shell configuration, e.g. ~/.bash_profile:
PATH=$PATH:$HOME/.rvm/bin
source /Users/<YOUR_USER_NAME>/.rvm/scripts/rvm
  • Using rvm, install new Ruby version:
rvm install ruby-2.5.7
  • Set the current/default version:
rvm use ruby-2.5.7 --default
  • Modify your Gemfile to use the new Ruby version. E.g.:
ruby '2.5.7'
  • Refresh the current Ruby version based on ./Gemfile by running:
rvm reload
  • After installing a new version, from your project dir do:
gem install bundler
bundle update

Upvotes: 1

adarsh
adarsh

Reputation: 308

Run

gem install bundler

or

gem update bundler 

which may fix your problem.

Upvotes: 1

Anand
Anand

Reputation: 6531

Delete Gemfile.lock and try with proper version of ruby and run bundle install.

Upvotes: 0

Related Questions