I have installed RVM along with ruby versions. However if I fire up the console and run the command rails server, bundle install, etc. I get this error
bash: /usr/bin/rails: /usr/bin/ruby1.8: bad interpreter: No such file or directory
But if I run rvm use 1.9.2
first, then everything is ok. I tried using `rvm use --default 1.9.2' but nothing changed. Does this mean it uses a different ruby from the ones in RVM? Thanks in advance!
You need to run
rvm use --default 1.9.2
, not justrvm use --default
.I just solved the same problem on Windows Vista.
My console was giving me this message:
I just edited the first line of this file:
And made it point to the correct location for ruby.exe, on my system, like this:
Et voilà, problem solved!
Explanation of rubygems bin folders and PATH
Oh. You didn't have rails installed in your rvm ruby, but you did in your system ruby.
Individual gems, like
rails
can have abin
directory that will contain executable helper scripts. Your system default rubygems is making symlinks from your system /usr/bin/ dir into the gem'sbin
folder for these helper executables.RVM provides a similar facility, except instead of polluting the system /usr/bin dir, it just appends its
~/.rvm/gems/#{rvm_gemset_string}/bin
folder to the PATH environment variable.Importing system Rubygems list into your new rvm rubies' gem directories
RVM by default will not import your gems from your system ruby installation into your rvm ruby installs. It makes a full clean fork of the entire ruby system including rubygems (the gem 'rubygems') and rubygems' gem list. When you
rvm install 1.9.2
it's like you've made a completely new install of everything used with ruby.If you'd like to get all your system ruby gems that you were previously using into your preferred rvm ruby, try this:
Original Answer/ Edits from @Telemachus
Try moving the lines that source rvm to the end of your
~/.bash_profile
or~/.bashrc
(whichever you have it in):.
You have rails installed in
/usr/bin
, which is probably before the rvm ruby bin path in your bashecho $PATH
variable, so it's finding the system rails install (/usr/bin/rails, a ruby script) which starts like this:#! /usr/bin/ruby18
You've gotta make the conflict stop happening, the best of all possible ways is making sure that RVM's bin dir is at the beginning of your PATH. This happens in the
#Load rvm environment
script that you added to your~/.bash_profile
when installing rvm. If you installed rvm as a system library rather than just for your user, this will be different.If you get to that case, ask @Telemachus.
You'll then need to ensure you've gotten the rails gem installed in your new rvm ruby as above.
Acceptance Test:
You'll find that when you've done
rvm use 1.9.2
, thenwhich ruby
will return something like~/.rvm/rubies/1.9.2/bin/ruby
, andwhich rails
should return something like~/.rvm/gems/*/bin/rails
.