Bundler Using Wrong Ruby Version

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:

  1. brew remove rbenv
  2. rm -rf ~/.rbenv
  3. Removed a line containing rbenv from ~/.zshrc

This removed rbenv. I then reinstalled using:

  1. brew install rbenv
  2. Then initialized using rbenv init. This effectively fixes the problem of rbenv. Now after restarting terminal, whenever I ran which 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

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


Related Topics



Leave a reply



Submit