ChatGPT解决这个技术问题 Extra ChatGPT

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

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?


A
Andrei Botalov

First of all, update your RVM installation by running 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).

Once that's done, you can ask RVM to list the ruby versions available to install by running 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.

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


For those who are getting ERROR: rvm update has been removed.rvm get latest / rvm get head are the correct ways to upgrade rvm now.
rvm get stable solved this error I had with MacOS: ERROR: Calling `brew list` to only list formulae is disabled! Use `brew list --formula` instead. Thanks!
o
oma

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

Some additional helpful tips, thanks to comments (@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

Also, you can rvm list known in order to see the available ruby versions that you can upgrade to.
Edit suggested by @Mauro Nidola "$ rvm upgrade 1.9.2 1.9.2-p0 should be changed to $ rvm upgrade 1.9.2-p0 1.9.2"
I can't see his comment @ACB, I'll change, your rep tells me I don't have to double check. I'm also updateding with James comment
@oma, I am from a different technology. So you might have to double check on that. That was an edit suggested by someone which got rejected as an invalid edit. Check this stackoverflow.com/review/suggested-edits/1365082. Ideally he should have posted as a comment, instead I did on his behalf.
V
Viktor

First update RVM:

rvm get stable

Then update your Ruby version:

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.

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.

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


L
Luke

like this:

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

I like this answer. I feel that upgrading the version of ruby sort of defeats the purpose of using rvm. Installing a separate version alongside p0 and then declaring the newer (or whichever) version as the default seems elegant.
Upgrading to the latest patch is sometimes necessary for security reasons - such as when vulnerabilities are discovered in a particular Ruby version.
p
pjammer

You can install any patch level by following the page in their 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.

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.


p
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.

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.

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.


H
Heikki

I guess its rvm install 1.9.2-head

You can see available rubies with rvm list known


will head get the latest patch level? i thought it was for the very latest version, meaning it could be something unstable and experimental.
Ahaa, true. I mixed the latest and patch level.
D
Dawid Woźniak

This blog post should be helpful: 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

While this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.