Ryan-Neal Mes
Ryan-Neal Mes

Reputation: 6263

Safe way to upgrade Ruby versions and gemsets in Rails applications

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?

Upvotes: 1

Views: 1202

Answers (3)

Ryan Condron
Ryan Condron

Reputation: 429

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.

Upvotes: 0

the Tin Man
the Tin Man

Reputation: 160601

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.

Upvotes: 1

B Seven
B Seven

Reputation: 45941

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.

Upvotes: 2

Related Questions