如何使用 rvm 将我的 ruby​​ 1.9.2-p0 升级到最新的补丁级别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4574318/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 23:59:45  来源:igfitidea点击:

How do I upgrade my ruby 1.9.2-p0 to the latest patch level using rvm?

ruby-on-railsrubyrvm

提问by Lan

My current version of ruby is ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.5.0]but I want to update it to the latest patch level using rvm. How can I do this?

我当前的 ruby​​ 版本是,ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.5.0]但我想使用 rvm 将其更新到最新的补丁级别。我怎样才能做到这一点?

回答by npad

First of all, update your RVM installation by running rvm get stable.

首先,通过运行更新您的 RVM 安装rvm get stable

To make sure you're running the new RVM version, you'll then need to run rvm reload(or just open a new terminal).

为确保您正在运行新的 RVM 版本,您需要运行rvm reload(或仅打开一个新终端)。

Once that's done, you can ask RVM to list the ruby versions available to install by running rvm list known.

完成后,您可以要求 RVM 列出可通过运行安装的 ruby​​ 版本rvm list known

In the output you should now see:

在输出中,您现在应该看到:

# MRI Rubies
...
[ruby-]1.9.2[-p320]
...

The square brackets around the patch level indicate that this is currently RVM's default patch level for ruby 1.9.2.

补丁级别周围的方括号表示这是当前 RVM 对 ruby​​ 1.9.2 的默认补丁级别。

Finally, to install the new ruby version, just run rvm install 1.9.2- and wait for it to compile!

最后,要安装新的 ruby​​ 版本,只需运行rvm install 1.9.2- 并等待它编译!

回答by oma

Upgrade ruby interpreter andkeep existing gemsets:

升级 ruby​​ 解释器保留现有的 gemsets:

$ rvm upgrade 1.9.2-p0 1.9.2
Are you sure you wish to upgrade from ruby-1.9.2-p0 to ruby-1.9.2-p136? (Y/n): Y

To replace with the latest stable release of 1.9.2. This avoids clutter.

替换为 1.9.2 的最新稳定版本。这样可以避免混乱。

Some additional helpful tips, thanks to comments (@Mauro, @James, @ACB)

一些额外的有用提示,感谢评论(@Mauro、@James、@ACB)

$ rvm list known
# NOTE: you probably want to upgrade your rvm first, as the list of known rubies seems to be coupled to the rvm version.
$ rvm get stable
$ rvm list known #pick your ruby

回答by Viktor Fonic

First update RVM:

首先更新RVM:

rvm get stable

Then update your Ruby version:

然后更新您的 Ruby 版本:

rvm upgrade 2.0.0

Choose yes for all the questions:

对所有问题选择是:

Are you sure you wish to upgrade from ruby-2.0.0-p195 to ruby-2.0.0-p247? (Y/n): Y
Are you sure you wish to MOVE gems from ruby-2.0.0-p195 to ruby-2.0.0-p247?
This will overwrite existing gems in ruby-2.0.0-p247 and remove them from ruby-2.0.0-p195 (Y/n): Y
Do you wish to move over aliases? (Y/n): Y
Do you wish to move over wrappers? (Y/n): Y
Do you also wish to completely remove ruby-2.0.0-p195 (inc. archive)? (Y/n): Y

If you wish to update your gems to the latest versions, you can do:

如果您希望将您的 gem 更新到最新版本,您可以执行以下操作:

rvm all do gem update

EDIT: I just did this today for the latest version of ruby 2.0.0 (I updated from ruby-2.0.0-p195 to ruby-2.0.0-p353). After that, I was getting segmentation fault when I tried to update gems. This happens because the gems were installed for ruby-2.0.0-p195 and some of them are incompatible with p353.

编辑:我今天刚刚为最新版本的 ruby​​ 2.0.0 做了这个(我从 ruby​​-2.0.0-p195 更新到 ruby​​-2.0.0-p353)。在那之后,当我尝试更新 gems 时,我遇到了分段错误。发生这种情况是因为 gems 是为 ruby​​-2.0.0-p195 安装的,其中一些与 p353 不兼容。

Now you can go and try to find the gems that are incompatible, but the easiest solution was to remove all installed gems and install them again. I simply removed gems/ruby-2.0.0-p353directory that was located in /usr/local/rvm. It could be somewhere else for you.

现在您可以去尝试查找不兼容的 gem,但最简单的解决方案是删除所有已安装的 gem 并重新安装它们。我只是删除gems/ruby-2.0.0-p353了位于/usr/local/rvm. 对你来说,它可能在别处。

Then I ran gem install bundlerand for each of my rails apps I did bundle install.

然后我跑了gem install bundler,对于我做的每个 rails 应用程序bundle install

回答by Amer

like this:

像这样:

rvm update; rvm reload
rvm install ruby-1.9.2-p136 
rvm --default ruby-1.9.2-p136

回答by pjammer

You can install any patch level by following the page in their wiki.

您可以按照其wiki 中的页面安装任何补丁级别。

Also, each ruby is independent, so you aren't really 'upgrading and keeping the gems' but installing a new patch version and then installing the gems in that new ruby environment.

此外,每个 ruby​​ 都是独立的,因此您并不是真正地“升级和保留 gem”,而是安装新的补丁版本,然后在新的 ruby​​ 环境中安装 gem。

This may be were gemsets come into play, however I don't use them.

这可能是宝石组发挥作用,但我不使用它们。

Do not forget to update your rvm too, just in case it's been awhile.

也不要忘记更新您的 rvm,以防万一已经有一段时间了。

回答by poetmountain

npad's answer definitely lays out the basics so I won't reiterate those steps, but there are several answers here suggesting using rvm upgrade. I know that rvm gives you the option, but it's a bit of a dangerous one.

npad 的答案肯定列出了基础知识,所以我不会重复这些步骤,但这里有几个答案建议使用rvm upgrade. 我知道 rvm 为您提供了选择,但这有点危险。

IMO, the safer and more "rvm way" is to first rvm installthe new ruby version, then use the rvm gemset copycommand to copy your gemset(s) to the new ruby version, e.g. rvm gemset copy 1.9.2-p0@some-gemset 1.9.2-p290@some-gemset. Then you can easily switch your project to using the newly-copied gemset (I recommend using an .rvmrcfile in your project directory) and see if your code fails. If it does, changing back to the old ruby version is just a matter of switching the gemset.

IMO,更安全和更“rvm 方式”是首先rvm install使用新的 ruby​​ 版本,然后使用rvm gemset copy命令将您的 gemset(s) 复制到新的 ruby​​ 版本,例如rvm gemset copy 1.9.2-p0@some-gemset 1.9.2-p290@some-gemset. 然后您可以轻松地将您的项目切换为使用新复制的 gemset(我建议使用.rvmrc您项目目录中的文件)并查看您的代码是否失败。如果是这样,改回旧的 ruby​​ 版本只是切换 gemset 的问题。

But even if you don't use gemsets (though I assume you do since you tagged rails on this question), the use of rvm upgradecan lead to unexpected failures. And if your code breaks, now you have to reinstall the old version again. Just take a bit more time and do it the clean way.

但是,即使您不使用 gemsets(尽管我假设您这样做了,因为您在此问题上标记了 rails),使用 也rvm upgrade可能导致意外失败。如果您的代码中断,现在您必须再次重新安装旧版本。只需多花一点时间并以干净的方式进行即可。

回答by Dawid Wo?niak

This blog post should be helpful: http://pogodan.com/blog/2011/09/06/ruby-1-9-3-for-development

这篇博文应该会有所帮助:http: //pogodan.com/blog/2011/09/06/ruby-1-9-3-for-development

essentials:

要点:

rvm get head
rvm reload

wget https://gist.github.com/raw/1008945/4edd1e1dcc1f0db52d4816843a9d1e6b60661122/ruby-1.9.2p290.patch
rvm install ruby-1.9.2-p290 --patch ruby-1.9.2p290.patch -n patched

回答by Heikki

I guess its rvm install 1.9.2-head

我猜它的 rvm install 1.9.2-head

You can see available rubies with rvm list known

你可以看到可用的红宝石 rvm list known