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

笑着哭i 提交于 2020-05-09 17:31:08

问题


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?


回答1:


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!




回答2:


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



回答3:


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.




回答4:


like this:

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



回答5:


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.




回答6:


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.




回答7:


I guess its rvm install 1.9.2-head

You can see available rubies with rvm list known




回答8:


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


来源:https://stackoverflow.com/questions/4574318/how-do-i-upgrade-my-ruby-1-9-2-p0-to-the-latest-patch-level-using-rvm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!