1
votes

I want to upgrade our Ruby version and a bunch of gems on our production website that we are currently running. We use RVM to manage our Ruby versions and gemsets.

I know how to install a new Ruby version using RVM and install gems in a gemset. I also understand that if I run bundle install it will install my gems into the Ruby version I am running the command from.

Is there some way to pre-create a Ruby version with a gemset in it and then swap my production site to use this new Ruby version and gemset? I know this can be done manually, but is there anyway to do it with a gemfile?

3
rvm + git + bundler + capistrano = no problems with version migrationsitsnikolay
I am already using rvm, git and bundler and from my understanding capistrano is used for the deployment process. What I am interested in is the how. I have a live site that is running, how can I create a new ruby version and gemset and then switch it over. Sometimes I run into bundle install problems and it can be quite nerve racking. Changing ruby versions and an entire new gemset is a big thing for us and I want to minimize downtime and risk. Preinstalling the version and gemsets then switching over to that feels safer than just running bundle install. Just how I feel.Ryan-Neal Mes
gemgets are depricated, instead them use bundler. If you user bundler you can simply switch gem versions any you want. Just make sure that locally your app works well with new gem versionsitsnikolay
Will my server continue to run fine if I switch versions, do a bundle install, then restart my server? Any documentation you could point me to on what you are talking about with bundler?Ryan-Neal Mes
If locally your app will work well, then on profuction it shold tooitsnikolay

3 Answers

2
votes

Yes, you can specify the Ruby version in the Gemfile:

source 'https://rubygems.org'
ruby '2.1.3'

This allows you to set the version that would be used if you deploy to Heroku, for example. Your question does not detail your production environment, so it's not clear if it can use the Ruby version in the Gemfile.

Locally, the app will run against whichever Ruby version is active with RVM. The only way to know if it will work is to run the specs against the new Ruby version. Your question did not mention specs, but if you have a complete set of specs then this is the proper way to find out if the new Ruby version will work.

1
votes

You can install new versions of Ruby and gem sets all day long without it affecting a running application. Once an application is running, it continues running under the same version of Ruby the entire time.

You can have RVM install new Rubies, manipulate gemsets, etc., as long as you don't remove the version of Ruby the application needs. If the binary disappears your app might crash/lock-up if the system needs to load something that has been deleted.

0
votes

This totally depends on your setup. I am anwsering for a Passenger/Apache setup.

With Passenger and Apache, you can set my PassengerRuby in the Apache Vhost file so it uses that particular version of Ruby, I would set it to your current ruby path and restart Apache like so:

PassengerRuby <path-to-ruby>

Then you you can install your new ruby version and gems, once you install everything you can change the PassengerRuby to the new ruby path and restart Apache. This should migrate your Ruby version smoothly, since you can always fallback to your old Ruby version.