简体   繁体   中英

What is the point of installing the same version of Ruby through RVM as the system Ruby?

I've been using the default system ruby version 1.8.7 without RVM for a few rails projects and have not run into any problems. I just recently installed RVM, and after running rvm requirements I get this output:

To use an RVM installed Ruby as default, instead of the system ruby:

    rvm install 1.8.7 # installs patch 357: closest supported version
    rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system.gems # migrate your gems
    rvm alias create default 1.8.7

I believe what these commands do are to install the same gems that have already been installed using the system ruby under the RVM installed ruby.

My questions are, am I right in what these commands do? and if I am right, why is it important to do this, because if I wanted to use an RVM installed Ruby of a different version like 1.9.2, wouldn't it already separate gems in that version from the system's ruby?

The one thing that springs to mind is, if you use the system Ruby, you'll use it slightly differently that RVM's Rubies--for example, you'll likely need to use sudo to install gems. Furthermore, you won't be able to use many of RVM's features, like gemsets, with the system Ruby.

好吧,我能想到的一个原因是,即使系统红宝石已更新,您也不必担心系统无法正常工作。

My questions are, am I right in what these commands do?

You are right in what they do. The first command installs Ruby 1.8.7, the second command installs all the gems currently install on your system Ruby installation in the new RVM Ruby 1.8.7 installation, and the third command sets your default version of Ruby to be the RVM Ruby 1.8.7.

and if I am right, why is it important to do this, because if I wanted to use an RVM installed Ruby of a different version like 1.9.2, wouldn't it already separate gems in that version from the system's ruby?

The second command is actually more of about convenience than necessity. Yes, the gems install in the RVM 1.8.7 will be completely separate from the ones installed in the system version of Ruby; however, if you didn't run the second command, you're RVM 1.8.7 would start out with almost no gems (only the defaults). That means that you would need to go through and manually install the gems that you need to get your project up and running. Instead of doing that, the second command allows you to just install the same gems you've already installed in the system version of Ruby to the RVM 1.8.7 version—it doesn't migrate them, it just makes a copy of them. After the second command, there are two distinct sets of the exact same gems: one in the system Ruby and one in the RVM 1.8.7 Ruby. So, if you were to update gems in either of the Rubies, they would get updated, but the other version's gems would be unaffected.

Hope this helps answer your question.

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