I set up RVM and used it to install Ruby and a few other libraries. As I was going through various tutorials and set-ups of other technologies like Rails, I began getting confused about what I should do via RVM and what I should just do as the tutorials suggest.
我设置了RVM并使用它安装Ruby和其他一些库。当我在浏览各种教程和其他技术(如Rails)的设置时,我开始对通过RVM应该做什么以及应该按照教程建议做什么感到困惑。
One example is the RubyGems tutorial here: http://rubygems.org/pages/download
一个例子是RubyGems教程:http://rubygems.org/pages/download
Should I download that tar file they are talking about? Seems unnecessary since that is what I thought RVM was for. Do I even need RubyGems? What is that for really?
我应该下载他们所说的tar文件吗?似乎没有必要,因为我认为RVM是为了这个。我还需要红宝石吗?这到底是为了什么?
Also, how do I actually get Rails? Is there a precise RVM command to actually download and install Rails?
另外,我如何获得Rails?是否有一个精确的RVM命令来实际下载和安装Rails?
3 个解决方案
#1
47
It helps me to think of RVM as a layer of abstraction between you and the ruby ecosystem.
它帮助我将RVM看作是您和ruby生态系统之间的抽象层。
Without RVM: ruby, gems, and ruby related binaries (like rake, spec, gem, etc) are all installed directly into your operating system directories.
没有RVM: ruby、gems和ruby相关的二进制文件(比如rake、spec、gem等)都直接安装到您的操作系统目录中。
With RVM: ruby related stuff is intercepted by rvm so that ruby, gems, and ruby related binares are "installed" into ~/.rvm dir in a nice, clean, organized way. RVM sits between ruby, gems, and related binaries and the operating system. It provides a way to have multiple ruby environments (with different gems and binaries) on the same machine.
使用RVM: RVM拦截ruby相关的内容,这样ruby、gems和ruby相关的binares就“安装”到~/中。rvm dir以一种漂亮、干净、有组织的方式。RVM位于ruby、gems和相关二进制文件和操作系统之间。它提供了在同一台机器上拥有多个ruby环境(拥有不同的gem和二进制文件)的方法。
So, no matter whether you have rvm installed or not, you should be able to run the commands almost exactly(*) as they appear in any tutorials out there on the web. In other words, you can sort of "forget" that RVM is installed; the ruby ecosystem should work just as if it wasn't installed.
因此,无论您是否安装了rvm,您都应该能够几乎完全地运行命令(*),就像它们在web上的任何教程中所显示的那样。换句话说,你可以“忘记”RVM已经安装;ruby生态系统应该像没有安装一样工作。
So, yep, you're gonna have to run gem install rails
, etc.
所以,是的,你需要运行gem安装rails等等。
Hope that helps clear the confusion.
希望这有助于消除困惑。
(*) There are some small differences. For example: you shouldn't run commands as sudo when RVM is installed.
(*)有一些细微的差别。例如:在安装RVM时,不应该像sudo那样运行命令。
#2
11
Should I download that tar file they are talking about?
我应该下载他们正在谈论的焦油文件吗?
No. Ruby 1.9+ includes gems. RVM retrofits it for 1.8+.
不。Ruby 1.9 +包括宝石。RVM对其进行了1.8+的改造。
In general, be careful with any directions you find on the internet explaining how to install anything, unless you have enough experience to understand completely what they want you to do. In particular, any time they want you to install something using sudo
or as root.
一般来说,要小心你在网上找到的任何说明如何安装任何东西,除非你有足够的经验去完全理解他们想要你做什么。特别是,当他们希望您使用sudo或作为root用户安装某些东西时。
Specifically, when working with RVM, you do NOT want to use sudo
to install Ruby, or any gem. RVM works by setting up a sandbox for your development, and relies on your account's environment, modifying your path so any Ruby requests go to the currently selected RVM-managed Ruby or gems or any commands they install. sudo
pushes your normal environment to the side, substituting root's temporarily, installs whatever you asked it to do with root's permissions, then reverts to your environment.
具体地说,在使用RVM时,您不希望使用sudo来安装Ruby或任何gem。RVM的工作方式是为您的开发设置一个沙箱,并依赖于您的帐户的环境,修改您的路径,以便任何Ruby请求都转到当前选定的RVM管理的Ruby或gems或它们安装的任何命令。sudo将您的正常环境推到一边,临时替换root的环境,用root的权限安装您要求它做的任何事情,然后返回到您的环境。
When you go to run the command, or find the gem, as you, it can't be found by RVM's Ruby, because the file was installed outside RVM's sandbox, or, it can't be read or modified, because it's owned by root. Whatever the actual cause, the end result will be weeping and gnashing of teeth.
当您运行该命令或找到gem时,RVM的Ruby无法找到它,因为该文件安装在RVM的沙箱之外,或者它不能被读取或修改,因为它属于root。无论真正的原因是什么,最终的结果将是哭泣和咬牙切齿。
RVM doesn't subvert the gem
functionality. gem
is used to install and manage Ruby gems, and RVM tweaks it to use the sandbox for all its machinations. You get added functionality because of RVM's support of gemsets, but gem
works as it always has, only it has "big brother", RVM, controlling its world.
RVM不会破坏gem的功能。gem用于安装和管理Ruby gems, RVM将其调整为使用沙箱进行所有的加工。由于RVM对gemsets的支持,您获得了附加的功能,但是gem还是一如既往地工作,只有它有“老大哥”RVM来控制它的世界。
#3
4
No need to install rubygems. RVM should have already installed rubygems. RVM is (in my opinion) useful for managing different installations of ruby (say 1.8.7 and 1.9.2) or different gemsets. If you just have one version of ruby and don't care about different gemsets, RVM isn't really that much of a change. If you want to just install rails, just use gem install rails
. If you have an existing rails 3 app, install bundler first gem install bundler
and then bundle install
to get rails and other gem dependencies.
无需安装rubygems。RVM应该已经安装了rubygems。RVM(在我看来)对于管理不同的ruby(比如1.8.7和1.9.2)或不同的gemsets非常有用。如果您只有一个ruby版本,而不关心不同的gemsets,那么RVM实际上并没有多大的变化。如果您只想安装rails,只需使用gem安装rails即可。如果您有一个现有的rails 3应用程序,安装bundler first gem安装bundler,然后捆绑安装以获得rails和其他gem依赖项。
#1
47
It helps me to think of RVM as a layer of abstraction between you and the ruby ecosystem.
它帮助我将RVM看作是您和ruby生态系统之间的抽象层。
Without RVM: ruby, gems, and ruby related binaries (like rake, spec, gem, etc) are all installed directly into your operating system directories.
没有RVM: ruby、gems和ruby相关的二进制文件(比如rake、spec、gem等)都直接安装到您的操作系统目录中。
With RVM: ruby related stuff is intercepted by rvm so that ruby, gems, and ruby related binares are "installed" into ~/.rvm dir in a nice, clean, organized way. RVM sits between ruby, gems, and related binaries and the operating system. It provides a way to have multiple ruby environments (with different gems and binaries) on the same machine.
使用RVM: RVM拦截ruby相关的内容,这样ruby、gems和ruby相关的binares就“安装”到~/中。rvm dir以一种漂亮、干净、有组织的方式。RVM位于ruby、gems和相关二进制文件和操作系统之间。它提供了在同一台机器上拥有多个ruby环境(拥有不同的gem和二进制文件)的方法。
So, no matter whether you have rvm installed or not, you should be able to run the commands almost exactly(*) as they appear in any tutorials out there on the web. In other words, you can sort of "forget" that RVM is installed; the ruby ecosystem should work just as if it wasn't installed.
因此,无论您是否安装了rvm,您都应该能够几乎完全地运行命令(*),就像它们在web上的任何教程中所显示的那样。换句话说,你可以“忘记”RVM已经安装;ruby生态系统应该像没有安装一样工作。
So, yep, you're gonna have to run gem install rails
, etc.
所以,是的,你需要运行gem安装rails等等。
Hope that helps clear the confusion.
希望这有助于消除困惑。
(*) There are some small differences. For example: you shouldn't run commands as sudo when RVM is installed.
(*)有一些细微的差别。例如:在安装RVM时,不应该像sudo那样运行命令。
#2
11
Should I download that tar file they are talking about?
我应该下载他们正在谈论的焦油文件吗?
No. Ruby 1.9+ includes gems. RVM retrofits it for 1.8+.
不。Ruby 1.9 +包括宝石。RVM对其进行了1.8+的改造。
In general, be careful with any directions you find on the internet explaining how to install anything, unless you have enough experience to understand completely what they want you to do. In particular, any time they want you to install something using sudo
or as root.
一般来说,要小心你在网上找到的任何说明如何安装任何东西,除非你有足够的经验去完全理解他们想要你做什么。特别是,当他们希望您使用sudo或作为root用户安装某些东西时。
Specifically, when working with RVM, you do NOT want to use sudo
to install Ruby, or any gem. RVM works by setting up a sandbox for your development, and relies on your account's environment, modifying your path so any Ruby requests go to the currently selected RVM-managed Ruby or gems or any commands they install. sudo
pushes your normal environment to the side, substituting root's temporarily, installs whatever you asked it to do with root's permissions, then reverts to your environment.
具体地说,在使用RVM时,您不希望使用sudo来安装Ruby或任何gem。RVM的工作方式是为您的开发设置一个沙箱,并依赖于您的帐户的环境,修改您的路径,以便任何Ruby请求都转到当前选定的RVM管理的Ruby或gems或它们安装的任何命令。sudo将您的正常环境推到一边,临时替换root的环境,用root的权限安装您要求它做的任何事情,然后返回到您的环境。
When you go to run the command, or find the gem, as you, it can't be found by RVM's Ruby, because the file was installed outside RVM's sandbox, or, it can't be read or modified, because it's owned by root. Whatever the actual cause, the end result will be weeping and gnashing of teeth.
当您运行该命令或找到gem时,RVM的Ruby无法找到它,因为该文件安装在RVM的沙箱之外,或者它不能被读取或修改,因为它属于root。无论真正的原因是什么,最终的结果将是哭泣和咬牙切齿。
RVM doesn't subvert the gem
functionality. gem
is used to install and manage Ruby gems, and RVM tweaks it to use the sandbox for all its machinations. You get added functionality because of RVM's support of gemsets, but gem
works as it always has, only it has "big brother", RVM, controlling its world.
RVM不会破坏gem的功能。gem用于安装和管理Ruby gems, RVM将其调整为使用沙箱进行所有的加工。由于RVM对gemsets的支持,您获得了附加的功能,但是gem还是一如既往地工作,只有它有“老大哥”RVM来控制它的世界。
#3
4
No need to install rubygems. RVM should have already installed rubygems. RVM is (in my opinion) useful for managing different installations of ruby (say 1.8.7 and 1.9.2) or different gemsets. If you just have one version of ruby and don't care about different gemsets, RVM isn't really that much of a change. If you want to just install rails, just use gem install rails
. If you have an existing rails 3 app, install bundler first gem install bundler
and then bundle install
to get rails and other gem dependencies.
无需安装rubygems。RVM应该已经安装了rubygems。RVM(在我看来)对于管理不同的ruby(比如1.8.7和1.9.2)或不同的gemsets非常有用。如果您只有一个ruby版本,而不关心不同的gemsets,那么RVM实际上并没有多大的变化。如果您只想安装rails,只需使用gem安装rails即可。如果您有一个现有的rails 3应用程序,安装bundler first gem安装bundler,然后捆绑安装以获得rails和其他gem依赖项。