通过RVM安装与系统Ruby相同版本的Ruby有什么意义?
我一直在一些 Rails 项目中使用不带 RVM 的默认系统 ruby 版本 1.8.7,并且没有遇到任何问题。我最近刚刚安装了 RVM,在运行 rvm requests
后,我得到了以下输出:
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
我相信这些命令的作用是安装已经在 RVM 安装的 ruby 下使用系统 ruby 安装的相同 gem。
我的问题是,我对这些命令的作用正确吗?如果我是对的,为什么这样做很重要,因为如果我想使用 RVM 安装的不同版本(例如 1.9.2)的 Ruby,它是否已经将该版本中的 gem 与系统的 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我想到的一件事是,如果您使用系统 Ruby,您的使用方式将与 RVM 的 Rubies 略有不同 - 例如,您可能需要使用 sudo 来安装 gem。此外,您将无法通过系统 Ruby 使用许多 RVM 功能,例如 gemset。
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.我能想到的原因之一是,即使系统 ruby 已更新,您也不想担心系统无法工作。
Well one reason I can think of is that you don't wanna worry about your system not working even if the system ruby gets updated.
他们所做的你是对的。第一个命令安装 Ruby 1.8.7,第二个命令在新的 RVM Ruby 1.8.7 安装中安装系统 Ruby 安装中当前安装的所有 gem,第三个命令将默认的 Ruby 版本设置为 RVM Ruby 1.8。 7.
第二个命令实际上更多的是为了方便而不是必要。是的,RVM 1.8.7 中安装的 gems 将与 Ruby 系统版本中安装的 gems 完全分开;但是,如果您没有运行第二个命令,则 RVM 1.8.7 开始时几乎没有 gem(只有默认值)。这意味着您需要仔细检查并手动安装启动和运行项目所需的 gem。相反,第二个命令允许您将已在 Ruby 系统版本中安装的相同 gem 安装到 RVM 1.8.7 版本 - 它不会迁移它们,而只是创建它们的副本。在第二个命令之后,有两组完全相同的 gem:一组在系统 Ruby 中,一组在 RVM 1.8.7 Ruby 中。因此,如果您要更新任一红宝石中的宝石,它们都会更新,但另一个版本的宝石不会受到影响。
希望这有助于回答您的问题。
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.
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.