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.
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
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 bundle install using wrong ruby with rvm when building native extension?
I was using the wrong bundle
.
$ which bundle
/usr/bin/bundle
Either the one included in Ubuntu 16.04 is old, or using the system-installed bundler doesn't work with rvm-installed Ruby.$ gem install bundler
Fetching: bundler-1.16.1.gem (100%)
...
1 gem installed
$ which bundle
/home/roger/.rvm/gems/ruby-2.3.4@junk-drawer/bin/bundle
That looks better.$ bundle
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Using bundler 1.16.1
...
Bundle complete! 1 Gemfile dependency, 9 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Lesson learned: when using rvm, remember to gem install bundler
as well. Incorrect ruby version when installing bundle in rails project
Steps to resolve this issueYour Ruby version is 2.4.0, but your Gemfile specified 2.3.1
1)rvm install ruby-2.3.1
2)gem install bundler
3)rvm use ruby-2.3.1
4)Bundle install
Related Topics
Set Ruby 2.0 Keyword Arguments with Attr_Accessor on Initialize
How to Install Wraith on Windows 7
Access an Instance Variable from Child Classes
Ruby Symbols Are Not Garbage Collected!? Then, Isn't It Better to Use a String
How to Parse Days/Hours/Minutes/Seconds in Ruby
How to Handle Omniauth Callbacks in Multiple Environments
Rails Application Helper Didn't Support Chinese Characters
Automatically Run Rspec When Plain-Old Ruby (Not Rails) Files Change
How to Display Image Pointed by Url in Rails
How Does The "#Map(&Proc)" Idiom Work When Introspecting Module Classes
Does Rails Support a Neat Way of Listening to a Udp Socket
Using Update_Columns in Rails 3
Resizing an Image with Mini_Magick
How to Create Line Breaks in Ruby
Recording Audio Through Rtmp/Rails
Ruby on Rails: Pluralize for Other Languages
How to Tell a Ruby Method to Expect a Specific Parameter Type