When writing Ruby programs, different versions may be selected due to different situations (for example, when there is a historical code ). RVM is an excellent ruby version management tool. With its help, RVM can easily switch between multiple versions. The following describes how to install and switch between ruby1.8.7 + rails2.1.0 and ruby (Latest Version) + rails (Latest Version) under javastux. 1. Install the GIT client: $ sudoapt-getupdate $ sudoapt-getins
When writing Ruby programs, different versions may be selected due to different situations (for example, when there is a historical code ). RVM is an excellent ruby version management tool. With its help, RVM can easily switch between multiple versions. The following describes how to install and switch between ruby1.8.7 + rails2.1.0 and ruby (Latest Version) + rails (Latest Version) under javastux.
1. Install the GIT client:
$ Sudo apt-get update $ sudo apt-get install build-essential git-core curl
2. Install the latest stable version of RVM:
$ Curl https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash-s stable RVM you can install RVM in the $ HOME/. rvm directory by using the above command.
3. Add RVM environment variables to the configuration file:
$ Echo '[[-s "$ HOME/. rvm/scripts/rvm"] & source "$ HOME/. rvm/scripts/rvm"'> ~ /. Bashrc
$ Source ~ /. Barshrc
4. install some external packages that RUBY depends on:
Sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g \
Zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf 5. Install OpenSSL:
$ Rvm pkg install openssl6. install RUBY:
After installing rvm, the program will automatically go to $ HOME /. in bashrc, add: PATH = $ PATH: $ HOME /. rvm/bin # Add RVM to PATH for scripting, so you can directly execute the rvm command.
Rvm install 1.8.77. Create the gemset of rails2.1.0:
$ Rvm gemset create rails2.1.0 # Switch to the gems of ruby1.8.7 + rails2.1.0
$ Rvm use 1.8.7@rails2.1.0
8. Install rails2.1.0:
$ Gem install rails -- version = 2.1.0
So, the completion of the ruby1.8.7 + ruby2.1.0 environment installation, after the only need to execute the rvm use 1.8.7@rails2.1.0 can switch the environment over.
9. Install the latest ruby and rails versions.
# The latest version is 1.9.3 $ rvm install 1.9.3 $ rvm use 1.9.3 # the latest version of rails is 3.2.3.
$ Rvm gemset create rails3.2.3 $ rvm use 1.9.3@rails3.2.3 $ gem install rails
Now, you can switch back and forth between the two versions:
Rvm use 1.8.7@rails2.1.0
Rvm use 1.9.3@rails3.2.3
Linuxidc @ www.linuxidc.com :~ /. Rvm/gems $ rvm use 1.8.7@rails2.1.0
Using/data/home/linuxidc/. rvm/gems/ruby-1.8.7-p358 with gemset rails2.1.0
Linuxidc @ www.linuxidc.com :~ /. Rvm/gems $ ruby-v
Ruby 1.8.7 (patchlevel 358) [x86_64-linux]
Linuxidc @ www.linuxidc.com :~ /. Rvm/gems $ rails-v
Rails 2.1.0
Linuxidc @ www.linuxidc.com :~ /. Rvm/gems $ rvm use 1.9.3@rails3.2.3
Using/data/home/linuxidc/. rvm/gems/ruby-1.9.3-p194 with gemset rails3.2.3
Linuxidc @ www.linuxidc.com :~ /. Rvm/gems $ ruby-v
Ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
Linuxidc @ www.linuxidc.com :~ /. Rvm/gems $ rails-v
Rails 3.2.3 ## if the gemset after @ symbol is not specified, the default gemset will be switched. Because our rails is installed under the specified gemset, # When you execute the rails command, the system will prompt that the command cannot be found.
Linuxidc @ www.linuxidc.com :~ /. Rvm/gems $ rvm use 1.9.3
Using/data/home/linuxidc/. rvm/gems/ruby-1.9.3-p194
Linuxidc @ www.linuxidc.com :~ /. Rvm/gems $ ruby-v
Ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
Linuxidc @ www.linuxidc.com :~ /. Rvm/gems $ rails-v
The program "rails" has not been installed yet. You can use the following command to install:
Sudo apt-get install rails
Linuxidc @ www.linuxidc.com :~ /. Rvm/gems $