bits about life, coding and stuff
Ever wondered what “freeze your gems” is all about?
Most rails app depend heavily on gems (rails itself is a gem!) and we somehow need to make sure that everything works together. And you really should care about this.
New gem updates may make backward incompatible changes that breaks the code. So freezing a gem puts it into the vendor folder of the application and will not updated on its own. Rails first looks into /vendor/rails before searching everywhere else for your gems.
Happy us – there’s a rake task that does all the hard work!
Freezing now copies unpacks rails into this special folder.
There’s also a “rake rails:unfreeze” – command, but if you simply wanna freeze your updated rails gems, run the freeze-command again.
To freeze your gems, you need to tell rails what you need. Therefore use the gem dependency feature of Rails 2.1+. Edit config/environment.rb
If you don’t know what you require, read the full list via gem list.
You can require a specific version or the latest (omitting the :version parameter); custom sources are also possible via :source => (e.g. the gems.github.com stuff)
Now tell rake that you want to install those gems (they should be installed anyway)
Next, we wanna freeze the gems too. The are copied into /vender/gems
The build command makes the native extensions.
The ‘F’ shows your freezed gems.
There are some gotchas however: Gems with native extensions(libxml…) can’t be frozen, as the OS code needs to live in the external OS.
http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies
http://stackoverflow.com/questions/799416/whats-the-point-of-freezing-your-rails-version-gems
http://www.softiesonrails.com/2008/1/3/freezing-your-rails-application
Related posts: