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

时间:2021-12-02 20:00:30

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修订29036)[x86_64-darwin10.5.0],但我想使用rvm将其更新到最新的补丁级别。我该怎么做呢?

8 个解决方案

#1


158  

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

首先,通过运行RVM来更新您的RVM安装。

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重载(或者只是打开一个新的终端)。

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

完成之后,您可以要求RVM通过运行已知的RVM列表来列出可以安装的ruby版本。

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安装1.9.2—并等待它编译!

#2


91  

Upgrade ruby interpreter and keep 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

#3


31  

First update 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:

如果你想更新你的宝石最新版本,你可以:

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时,我得到了分段错误。这是因为gem是为ruby-2.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-p353 directory that was located in /usr/local/rvm. It could be somewhere else for you.

现在,您可以尝试找到不兼容的gem,但是最简单的解决方案是删除所有已安装的gems并再次安装它们。我只是删除了gems/ruby-2.0 -p353目录,该目录位于/usr/local/rvm中它可能是你的其他地方。

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

然后我运行gem安装bundler,并对我的每个rails应用程序进行捆绑安装。

#4


13  

like this:

是这样的:

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

#5


2  

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环境中安装gems。

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,以防已经有一段时间了。

#6


2  

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升级。我知道rvm给了你一个选择,但是有点危险。

IMO, the safer and more "rvm way" is to first rvm install the new ruby version, then use the rvm gemset copy command 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 .rvmrc file 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.

在我看来,更安全、更“rvm”的方法是,首先安装新的ruby版本,然后使用rvm gemset copy命令将gemset(s)复制到新的ruby版本,例如rvm gemset copy 1.9.2-p0@some-gemset 1.9.2- p290@someset @ some9.2 @ gemset @ gemset -gemset 1.9.2 @ 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 upgrade can 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升级也可能导致意外的失败。如果您的代码中断,现在您必须重新安装旧版本。多花点时间,用干净的方式做。

#7


1  

I guess its rvm install 1.9.2-head

我猜它的rvm安装了1.9.2个头。

You can see available rubies with rvm list known

您可以看到有rvm列表的可用红宝石。

#8


1  

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-3

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

#1


158  

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

首先,通过运行RVM来更新您的RVM安装。

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重载(或者只是打开一个新的终端)。

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

完成之后,您可以要求RVM通过运行已知的RVM列表来列出可以安装的ruby版本。

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安装1.9.2—并等待它编译!

#2


91  

Upgrade ruby interpreter and keep 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

#3


31  

First update 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:

如果你想更新你的宝石最新版本,你可以:

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时,我得到了分段错误。这是因为gem是为ruby-2.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-p353 directory that was located in /usr/local/rvm. It could be somewhere else for you.

现在,您可以尝试找到不兼容的gem,但是最简单的解决方案是删除所有已安装的gems并再次安装它们。我只是删除了gems/ruby-2.0 -p353目录,该目录位于/usr/local/rvm中它可能是你的其他地方。

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

然后我运行gem安装bundler,并对我的每个rails应用程序进行捆绑安装。

#4


13  

like this:

是这样的:

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

#5


2  

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环境中安装gems。

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,以防已经有一段时间了。

#6


2  

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升级。我知道rvm给了你一个选择,但是有点危险。

IMO, the safer and more "rvm way" is to first rvm install the new ruby version, then use the rvm gemset copy command 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 .rvmrc file 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.

在我看来,更安全、更“rvm”的方法是,首先安装新的ruby版本,然后使用rvm gemset copy命令将gemset(s)复制到新的ruby版本,例如rvm gemset copy 1.9.2-p0@some-gemset 1.9.2- p290@someset @ some9.2 @ gemset @ gemset -gemset 1.9.2 @ 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 upgrade can 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升级也可能导致意外的失败。如果您的代码中断,现在您必须重新安装旧版本。多花点时间,用干净的方式做。

#7


1  

I guess its rvm install 1.9.2-head

我猜它的rvm安装了1.9.2个头。

You can see available rubies with rvm list known

您可以看到有rvm列表的可用红宝石。

#8


1  

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-3

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