Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the point of freezing your Rails version/gems?

What does that mean?

In the instructions for a project, it said to "freeze the Rails gems". Is that different from freezing the Rails version?

What's freezing about?

like image 799
Bijou Avatar asked Apr 28 '09 19:04

Bijou


2 Answers

If one of the authors of a gem you use introduce a new version of the gem, there is a possibility the new version introduces backwards incompatible changes that would break your code.

Freezing a gem puts it into the vendor folder of your application, and it will not be automatically updated on its own. Rails will use this version of the gem instead.

This allows you to update the gem on your system for other apps, while having your sole app use the version of the gem that you have always been working with, and therefore is stable.

This applies to the rails gem itself as well, as newer versions of rails might eventually cause something in your app to break, freezing it will prevent the system wide update (and, once again, allows you to update other apps on your machine, while leaving the app you freeze rails in at that version number.

like image 83
phillc Avatar answered Oct 14 '22 20:10

phillc


I think Phillc hit the nail on the head with his comments.

Whenever you have an application running in a production environment that people count on working, you have to have a mechanism for 'freezing' the environment. Updating rails could cause your application to stop working correctly.

It could be something minor or something that stops your users from getting their work done.

Just google 'rails gem update breaks my app' to see some tails of woe.

Igor Minar has a good blog entry on why you should freeze both gems and Rails as well as discussing how you can now set specific gem version dependencies in Rails.

You can freeze Rails, you can freeze gems, you can set dependency on specific gem version in your environment.rb file.

The reason you would do this is to ensure that your app does not break when an updated version of a gem or of Rails is released. Freezing lets you test an update on a separate machine, make sure it passes all of your automated test suites, lets your users put the updated app through its paces, and then (after a good backup) you apply the update to the gem or to Rails.

like image 44
sean lynch Avatar answered Oct 14 '22 20:10

sean lynch