Ruby version management tools RVM installation and use tutorials _ruby topics

Source: Internet
Author: User

RVM is a command-line tool that provides the management and switching of a convenient, multiple-version Ruby environment.

https://rvm.io/

If you are going to learn ruby/rails, RVM is one of the essential tools.

All commands here are operated under user privileges, and any command is best not to use sudo.
RVM Installation

$ curl-l Get.rvm.io | Bash-s Stable
$ source ~/.BASHRC
$ source ~/.bash_profile

Modify the RVM Ruby installation source to the domestic Taobao mirror server, which can improve the installation speed

$ sed-i-E ' s/ftp\.ruby-lang\.org\/pub\/ruby/ruby\.taobao\.org\/mirrors\/ruby/g ' ~/.rvm/config/db

Ruby Installation and switching

Listing known versions of Ruby

RVM list known

Install a Ruby version

RVM Install 2.2.0

The latest 2.2.0 is installed here and the RVM list known can be installed.

Toggle Ruby Version

RVM Use 2.2.0

If you want to set it as the default, this will be the default Ruby version of the new console that you open later

RVM Use 2.2.0--default 

Query for Ruby already installed

RVM List

Uninstall an installed version

RVM Remove 1.8.7

The use of Gemset

RVM not only provides an environment in which multiple Ruby versions coexist, but can also manage different gemset depending on the project.

Gemset can be understood as an independent virtual GEM environment where each gemset is independent of each other.

For example, you have two projects, one is Rails 2.3 and one is RAILS3. Gemset can help you easily build two GEM development environment, and easy to switch.

Gemset is appended to the Ruby language version, for example, you used 1.9.2 to create a gemset called RAILS3, which RAILS3 does not exist when switching to 1.8.7.
Establish Gemset

RVM use 1.8.7
RVM gemset Create Rails23

You can then set the established Gemset as the current environment
Use can be used to toggle language or Gemset

The premise is that they have been installed (or established). And you can see it in the List command.

RVM use 1.8.7
RVM use 1.8.7@rails23

All the installed gems are then installed under this gemset.
Lists the current Ruby Gemset

RVM Gemset List

Clear the Gem in the Gemset

If you want to clear all the gems of a gemset and want to reinstall all gems, you can do so

RVM Gemset Empty 1.8.7@rails23

Delete a Gemset

RVM Gemset Delete rails2-3

Project Auto Load Gemset

RVM can also load Gemset automatically.
For example, we have a Rails 3.1.3 project that requires a 1.9.3 version of Ruby, and the entire process can be this way.

RVM Install 1.9.3
RVM use 1.9.3 rvm gemset
Create rails313
RVM use 1.9.3@rails313

Enter the project directory below to create a. rvmrc file.

In this file you can simply add a command:

RVM Use 1.9.3@rails313

Then no matter what your current Ruby settings are, RVM will help you load Ruby 1.9.3 and rails313 Gemset when the CD gets to this project.
use RVM to quickly deploy Nginx + passenger

First install passenger

Gem Install passenger

Then use Passenger-install-nginx-module to install Nginx and deployment.

Because this step requires root permissions (because to compile Nginx) you can use Rvmsudo this thing (this thing is really a good thing).

Rvmsudo Passenger-install-nginx-module

Then you will choose to download the Nginx source code automatically compiled installation, or choose their own Nginx source location.

Select Nginx manually installed can add other compilation parameters to facilitate custom compilation Nginx.

Then download the installation all the way. The default installation location is/opt/nginx.

Then look at the nginx.conf, all configured for you, just add the root position (yourapp/public) on it.

When I first installed it, I exclaimed, "That's awesome."

Ps:rvm is a good thing to do, smart, (most) after the failure of the operation will tell you the reason, and then tell you what to install the Lib and so on, very suitable for novice veteran use, is simply a home travel necessary medicine.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.