Reputation: 79
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
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.
brew install asdf
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
asdf plugin add ruby
asdf install ruby 2.6.10
asdf global ruby 2.6.10
(change 'global' to 'local' if you only intend to set it locally)asdf current ruby
gave me 2.6.10ruby -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 rvmBy 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
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
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
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:
rvm get head
~/.bash_profile
:PATH=$PATH:$HOME/.rvm/bin
source /Users/<YOUR_USER_NAME>/.rvm/scripts/rvm
rvm install ruby-2.5.7
rvm use ruby-2.5.7 --default
ruby '2.5.7'
rvm reload
gem install bundler
bundle update
Upvotes: 1
Reputation: 308
Run
gem install bundler
or
gem update bundler
which may fix your problem.
Upvotes: 1
Reputation: 6531
Delete Gemfile.lock
and try with proper version of ruby and run bundle install
.
Upvotes: 0