简体   繁体   中英

Switching between Compiled and rvm versions of Ruby

I'm currently trying to learn Rails, and in the process, I compiled Ruby on my own, as I did with Python, expecting the same process.

However, after digging a bit, I eventually gave up and just started using rvm. I've installed everything, but after a few moments realized my system (Ubuntu 11.10) thought I was using the version of Ruby I compiled (which was missing openssl ) rather than rvm's version of Ruby, which was complete.

I "uninstalled" it according to this post , and after reinstalling rvm's Ruby with openssl , iconv , and rails, I'm now getting the following error message:

secretasianman@ubuntu:~/Projects/first_app$ rails server
bash: /usr/local/bin/rails: /usr/local/bin/ruby: bad interpreter: No such file or directory

Any idea on how to fix this? I've edited the last two lines of ~/.bashrc to read like the following, but to no avail.

PATH=$PATH:$HOME/.rvm/bin:$HOME/.rvm/rubies/ruby-1.9.3-p125/bin # Add RVM to PATH for scripting
export PATH

try adding to ~/.bashrc

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

then in a new shell try

ruby -v 

You may want to give a look to rbenv which works in a simpler way (just changing PATH)

To install it (I use .bashrc instead of .bash_profile). Make sure you remove all traces of rvm:

$ cd
$ git clone git://github.com/sstephenson/rbenv.git .rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

And restart your shell:

$ exec $SHELL

To get the "rbenv install" command to install a particular version, install also ruby-build . rbenv separates the two commands so that rbenv also works with custom built rubies.

$ git clone git://github.com/sstephenson/ruby-build.git
$ cd ruby-build
$ ./install.sh

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM