Is there a way to upgrade from Ruby 1.8.7 to 1.9.2 without having to reinstall gems and rails?
In more details... I have a CentOS machine running Passenger alongside other Apache/httpd projects (PHP) and I wonder if there is some way I can upgrade my Ruby version without breaking any current running projects. I found a lot of examples on upgrading which are fine but they all include reinstalling rails and in some cases rubygems. They even require you to pass some code in your controller for encoding utf-8. There is no time doing this because it is a live server running sharp projects.
I wonder if you can do something like this:
E.g
- Installing new Ruby v开发者_StackOverflow社区ersion 2.Fix any symbolic links
- Possible bundle update
- Restart Apache/httpd server
I don't have RVM installed because I thought it included more hassle than just installing Ruby itself.
Everyone's talking so good about the performance in version 1.9.X I thought it might be worth the upgrade.
AFAIK - no, you cannot do that because some gems (including passenger) have native extensions (read: have parts written in C), which are compiled with 1.8.7 version headers/code. They'd most probably are incompatible with ruby 1.9.x. Also, ruby's stdlib is in different location (maybe this could be changed by some env variable?). But still, main issue stays the native extensions for gems.
If you install Ruby 1.9.2 to a different location (e.g. /usr/bin/ruby1.9 or /usr/local/bin/ruby), you could update without a major downtime. You would have to recompile your gems though.
- Install Ruby 1.9.2
- Recompile Passenger and configure the Apache to use this passenger and the new Ruby interpreter (do not restart yet)
- Deploy your application using the new Ruby interpreter, bundle the gems
- Restart the Apache
Haven't tried that, so wait for some comments about flaws in this workflow.
It's also possible to use multiple ruby versions in the same webserver using Passenger 3, see http://blog.phusion.nl/2010/09/21/phusion-passenger-running-multiple-ruby-versions/ for details. You could set up a ruby 1.9 app with Passenger stand alone and test everything before switching.
精彩评论