如何在使用RVM时安装Ruby gems? [英] How do I install Ruby gems when using RVM?

查看:80
本文介绍了如何在使用RVM时安装Ruby gems?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立了RVM并用它来安装Ruby和其他一些库。当我正在浏览Rails等其他技术的各种教程和设置时,我开始对通过RVM应该做什么感到困惑,以及我应该如教程中的建议那样做。



一个例子是这里的RubyGems教程:
http://rubygems.org/pages/download



我应该下载他们正在讨论的tar文件吗?似乎没有必要,因为这是我认为RVM的目的。我甚至需要RubyGems吗?那真的是什么?

另外,我该如何获得Rails?有没有一个精确的RVM命令来实际下载和安装Rails?

解决方案

它帮助我将RVM视为一个抽象层你和红宝石生态系统之间。

没有RVM:ruby,gem和ruby相关的二进制文件(如rake,spec,gem等)都直接安装到操作系统目录中。

使用RVM:Ruby相关的东西被rvm拦截,以便ruby,gem和ruby相关的binares被安装到〜/ .rvm目录中, ,有组织的方式。 RVM位于ruby,宝石和相关的二进制文件和操作系统之间。它提供了在同一台机器上拥有多个ruby环境(使用不同的gem和二进制文件)的方法。



因此,无论您是否安装了rvm,您都应该能够运行命令几乎完全(*),因为它们出现在任何教程中网页。换句话说,您可以忘记RVM已安装;红宝石生态系统应该就好像它没有安装一样。



因此,你必须运行 gem install rails 等。



希望有助于消除混淆。

(*)有一些小的差异。例如:安装RVM时,不应将命令作为sudo运行。

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.

One example is the RubyGems tutorial here: 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?

Also, how do I actually get Rails? Is there a precise RVM command to actually download and install Rails?

解决方案

It helps me to think of RVM as a layer of abstraction between you and the ruby ecosystem.

Without RVM: ruby, gems, and ruby related binaries (like rake, spec, gem, etc) are all installed directly into your operating system directories.

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.

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.

So, yep, you're gonna have to run gem install rails, etc.

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时安装Ruby gems?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆