Incorrect ruby version when installing bundle in rails project
Your Ruby version is 2.4.0, but your Gemfile specified 2.3.1
Steps to resolve this issue
1)rvm install ruby-2.3.1
2)gem install bundler
3)rvm use ruby-2.3.1
4)Bundle install
bundler using system ruby version instead of downloaded
Okkk, so after hours and with help from comments here and the answer given above I was able to get it to work.
The problem it seemed was that rbenv was not properly setup. To fix it, it's either to uninstall and install again. Did this through:
brew remove rbenv
rm -rf ~/.rbenv
- Removed a line containing rbenv from
~/.zshrc
This removed rbenv. I then reinstalled using:
brew install rbenv
- Then initialized using
rbenv init
. This effectively fixes the problem of rbenv. Now after restarting terminal, whenever I ranwhich ruby
, I'd get:
/Users/Mahmoud/.rbenv/shims/ruby
meaning in short that the system now relies on rbenv for its ruby version management instead of looking in the system. This is crucial for the working of rbenv, and in essence this is it's whole "raison d'etre"; to take the job of managing ruby on your pc away from your pc.
After this step I ran gem install bundler
. Following this step when I run which bundle
it would give:
/Users/Mahmoud/.rbenv/shims/bundle
so everything is in place and working fine
Wrong ruby version being used
If using RVM, make sure that in your ~/.bash_profile file the path for rvm comes before the other paths.
For example, put this into your ~/.bash_profile before any PATH declarations:
export PATH=:~/.rvm/bin/:~/.rvm/gems/gems/
Then the rest of your export declarations which might look like this (this is just an example, you don't need to put it in, I'm just including it so you see how the file might look like, but the above line you definitely need):
export PATH=:~/bin/:/usr/local/Cellar/mysql/bin:/usr/local/Cellar:/usr/local/sphinx:/usr/sbin:$PATH
Finally, if, like me, you ditched RVM and went with rbenv then substitute the first export PATH
line with this:
export PATH="$HOME/.rbenv/bin:$PATH"
These changes should make the system look at your RVM files before the built-in ones in /System/Library/Frameworks/Ruby.framework
Good luck.
Related Topics
Why Is the Splat Used Inside an Array Definition Here
Access Attributes/Methods Comments Programmatically in Ruby
How to Stop Savon from Adding Prefixes to Soap.Body
Nanoc Changing the Base Path When Deploying Page in Github
How to Simplify or Clean Up This Anagram Method
When to Use Keyword Arguments Aka Named Parameters in Ruby
Argumenterror: Unknown Key: :Conditions. Valid Keys Are: :Class_Name, :Class, :Foreign_Key
Group Users by Age Range in Ruby
What Does It Mean to Yield Within a Block
Ruby: How to Convert Ip Range to Array of Ip'S
Fast-Stemmer Installation Problems
Rails Error Message Displays Key and I Only Want Value
Is There a Groovy Equivalent of the Ruby Timeout Module
Writing Ruby Console Output to Text File
Why Does the Rand() Return Always the Same Number
Ruby on Rails: Converting "Somewordhere" to "Some Word Here"