1 - Installing RVM
$ sudo gem install rvm
$ (rvm-install已过时)
$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
Finally put this lines in your .bash_profile or .bashrc:
if [[ -s $HOME/.rvm/scripts/rvm ]] ; then
source $HOME/.rvm/scripts/rvm
fi
Restart your terminal, Rvm should be working by now.
2 - Installing ruby inside your rvm
$ rvm install 1.8.7
Will install ruby 1.8.7
$ rvm install ruby-head
Will install ruby 1.9.2 or newer.
3 - Setting up rvm to use your specific ruby version
$ rvm use 1.8.7
To use just this time.
$ rvm use 1.8.7 --default
To use always this version.
If you are using any other ruby replace the “1.8.7” for your version.
4 - Installing rails 2 and rails 3 RC inside different gemsets
firstly select a ruby version
$ rvm use 1.8.7
You can separate your rails versions inside gemsets:
Rails 2:
Create the gemset:
$ rvm gemset create rails2
Setting up rvm to use always this gemset:
$ rvm use 1.8.7@rails2 --default
Installing rails 2:
$gem install rails
#前面不能加sudo,否则就安装到系统默认的gemsets而未安装到rvm的gemsets
$rvm gem list
$gem list
Rails 3:
Create the gemset:
$ rvm gemset create rails3
Setting up rvm to use always this gemset:
$rvm use 1.8.7@rails3 --default
Installing rails 3:
$gem install rails --pre
5 - Switching between different rails versions
Switching back to your system Ruby
rvm system
Back to your Rails3.0 environment
rvm 1.9.2@rails3
Switching to rails 2:
$ rvm use 1.8.7@rails2
$ rails -v
Rails 2.3.5
Switching to rails 3:
$ rvm use 1.8.7@rails3
$ rails -v
Rails 3.0.0.rc
rvm install ree
ERROR: There has been an error while trying to run the ree installer. Halting theinstallation.
Installed ruby 1.9.2 via RVM and getting the following error?
no such file to load -- openssl
Try getting RVM to install the required openssl files. Unfortunately this means removing ruby and installing it again.
rvm pkg install openssl
rvm remove 1.9.2
rvm install 1.9.2 --with-openssl- dir =$HOME/.rvm /usr
But hey, it works.
rvm no such file to load readline
rvm package install readline
rvm remove 1.8.7-p330
rvm install 1.8.7-p330 --with-readline-dir=$rvm_path/usr
Problem
When you try to run the console rails c
in a new Rails 3.0.3 application, and when you use rvm, you get the following error:
no such file to load -- readline (LoadError)
Solution
It’s quite like likely that the readline libraries are missing from your installation. To find out which ones go to the directory that the error is indicating (ie):
$cd /.rvm/src/ruby-1.8.7-p352/ext/readline
$ruby extconf.rb
$make
$sudo make install
If you get something like:checking for readline/readline.h... no
checking for editline/readline.h... no
then you are probably missing the neccessary header files for readline.
1、so install them in your system:
sudo urpmi readline-dev
(ie in Mandriva)
In Debian you will need to install libreadline5-dev and
libncurses5-dev (apt-get install).
When the package is installed successfully run the following again:
ruby extconf.rb
make
sudo make install
You should now be able to go back to your project and run rails c
with no errors.
2、if apt-get error, you can install from src code
从网上下载安装包下来安装
http://ftp.cn.debian.org/debian/pool/main/r/readline5/libreadline5-dev_5.2-7_i386.deb
http://ftp.cn.debian.org/debian/pool/main/n/ncurses/libncurses5-dev_5.7+20100313-5_i386.deb
3、下载 ruby-1.8.7-p352的软件包
找到 ruby-1.8.7-p352/
ext/readline copy to /.rvm/src/ruby-1.8.7-p352/ext/readline
$ruby extconf.rb
$make
$sudo make install
4、安装ruby的版本和系统默认的ruby版本相同
rvm install 1.8.7-p72 --with-openssl-dir=$HOME/.rvm/usr