问题
I tried looking for an answer for about an hour but no luck. I have installed ruby-2.0.0
with my rvm but the system only detects the old ruby-1.9.3
!I changed the sym link in /usr/bin/ruby
to point to my ~/.rvm
ruby and now I get the following when I run ruby -v
ruby 2.0.0p451 (2014-02-24 revision 45167) [x86_64-linux]
However when I try to start a rails server
I get the error which says my current ruby version is 1.9.3
I ran gem env
and got a surprising results:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.9.1
- /home/username/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "install" => "--no-rdoc --no-ri"
- "update" => "--no-rdoc --no-ri"
- REMOTE SOURCES:
- http://rubygems.org/
As you can see it is pointing to the wrong location. I tried modifying .gemrc
to get it to work but it still refuses to change it's ruby installation directory. I have no idea how to fix it. I tried removing them all and starting fresh but apparently they are not installed via apt-get
so I don't know how to remove them!
Any help will be very much appreciated. Just for further info:
$ gem -v
1.8.23
回答1:
First list ruby versions in RVM
rvm list
For example mine says
ruby-1.9.3-p484 [ x86_64 ]
=* ruby-2.1.0 [ x86_64 ]
# => - current
# =* - current && default
# * - default
To use a ruby version use command like
rvm use ruby-2.1.0
You can set default ruby like this
rvm use --default ruby-2.1.0
Now check your ruby version
ruby -v
To ensure that non-interactive shells have access to RVM
Edit .bashrc
using this command
sudo gedit /home/$USER/.bashrc
Make sure you have these lines there. If not add it.
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s "/home/`whoami`/.rvm/scripts/rvm" ]] && source "/home/`whoami`/.rvm/scripts/rvm"
Now edit your .bash_profile using this command
sudo gedit /home/$USER/.bash_profile
Make sure you have these lines there. If not add it.
if [ -f "$HOME/.bashrc" ]; then
source $HOME/.bashrc
fi
Restart your terminal.
回答2:
If you want to get rid of rvm completely, use the command
rvm implode
But apart from that, once you install ruby 2.0.0
using rvm, are you using it also? Use the command
rvm use 2.0.0
and that should set it. To check which ruby is being used, try the command
which ruby
来源:https://stackoverflow.com/questions/22418070/link-ruby-to-rvm