简体   繁体   English

安装RVM后找不到Ruby 1.9.2

[英]Can't find Ruby 1.9.2 after installing RVM

I'm on Linux Ubuntu 12.04, and I first installed Ruby 1.9.2. 我在Linux Ubuntu 12.04上,首先安装了Ruby 1.9.2。

After I tried installing rvm to use Octopress, ruby --version in bash results in ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux] 在尝试安装rvm以使用Octopress之后,bash中的ruby --version导致ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

How can I use RVM with ruby 1.9.2? 如何将RVM与ruby 1.9.2一起使用?

I don't really understand what RVM is all about... 我不太了解RVM到底是什么...

The 1.9.2 version you installed first is not accessible from rvm . rvm无法访问您首先安装的1.9.2 version

While working with rvm , only the list of rubies installed through rvm is served. 使用rvm ,仅提供通过rvm安装的红宝石列表。 The previously installed versions of ruby - while still present in the filesystem - are not included. 不包括先前安装的ruby版本(尽管仍存在于文件系统中)。

With the steps you have done so far, you have a 1.9.2 version installed in one location, and a 1.8.7 version installed as part of rvm . 到目前为止,完成所有步骤后,您将在一个位置安装了1.9.2 version ,并在rvm安装了1.8.7 version

Install 1.9,2 version by running the rvm install 1.9.2 command. 通过运行rvm install 1.9.2命令安装1.9,2 version After that, when you run the rvm list command, you should see an output similar to the following: 之后,当您运行rvm list命令时,应该看到类似于以下内容的输出:

$ rvm list

rvm rubies

   ruby-1.8.7-p358 [ i686 ]
=* ruby-1.9.2-p320 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

You can switch between different versions of ruby managed by rvm with the rvm use 1.8.7 / rvm use 1.9.2 commands. 您可以rvm use 1.8.7 / rvm use 1.9.2命令在rvm use 1.8.7管理的不同版本的Ruby中进行rvm

Here's a short blogpost with a good intro to rvm: Get started right with RVM 这是一篇简短的博文,其中对rvm有一个很好的介绍: RVM入门

Perhaps you have not yet switched to the ruby version with: 也许您尚未通过以下方式切换到红宝石版本:

rvm use 1.9.2 (assuming you did rvm install 1.9.2)

for a more general explanation I gave an answer here which might help . 对于更一般的解释,我在这里给出了答案,可能会有帮助

RVM is a version manager which enables you to decide which of multiple installed Ruby versions you want to use in your current shell session. RVM是一个版本管理器,它使您能够决定要在当前Shell会话中使用多个已安装Ruby版本中的哪个。 RVM does this by providing a shell function named rvm which can be used to switch between versions in the current session. RVM通过提供一个名为rvm的shell函数来实现此目的,该函数可用于在当前会话的版本之间进行切换。 This changes environment variables, especially the GEM_HOME and PATH, to match the currently selected Ruby installation. 这将更改环境变量,尤其是GEM_HOME和PATH,以匹配当前选择的Ruby安装。

Every installed Ruby version can be selected by a specific identifier string. 可以通过特定的标识符字符串选择每个已安装的Ruby版本。 If you had a system-wide Ruby installation already before you installed RVM, that one should be referenced by the string system . 如果在安装RVM之前已经进行了系统级的Ruby安装,则应该由string system引用该system The newly installed version in your case should be called 1.9.2 . 在您的情况下,新安装的版本应称为1.9.2

To make RVM work as intended, it is necessary to load the rvm shell function into your shell. 为了使RVM正常工作,必须将rvm shell函数加载到您的shell中。 How to do this is described in the RVM Installation Documentation in section 2 - "Load RVM into your shell sessions as a function". RVM安装文档的第2节-“将RVM作为功能加载到Shell会话中”中描述了如何执行此操作。

You can see if the shell function is correctly loaded when the command type rvm | head -n1 您可以查看命令type rvm | head -n1 shell时是否正确加载了shell函数type rvm | head -n1 type rvm | head -n1 responds with: type rvm | head -n1响应:

rvm is a shell function

If not correctly loaded it will tell you something like this: 如果未正确加载,它将告诉您以下信息:

rvm is /home/someone/.rvm/bin/rvm

If you finally have it working you can switch your active Ruby version with commands like rvm 1.9.2 or rvm system . 如果最终可以使用,则可以使用rvm 1.9.2rvm system类的命令来切换活动的Ruby版本。 You can get a list of all Ruby versions and their identifier strings recognized by RVM by the command rvm list . 您可以通过rvm list命令获得所有Ruby版本及其RVM识别的标识符字符串的rvm list

You can also specify which Ruby version shall be enabled in all new shell sessions from the beginning by issuing the following command once: 您还可以通过一次发出以下命令来指定从一开始就在所有新的Shell会话中启用哪个Ruby版本:

rvm --default 1.9.2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM