Installing and Freezing Gems
Posted by Administrator on 24 December 2009 10:48 PM
When Rails 1.1.0 was released, many web hosting companies who did the major upgrade experienced failed RoR applications due to incompatibilities.

However some forward thinking developers avoided the downtime by "freezing" their gems. This involves unpacking the gems into the vendor folder of a Rails app.

It is highly recommended that RoR developers freeze their gems to allow total control of the production environment. Also, you do not have to wait for someone to install a special gem you require.

Create a .gems directory in your root and download/install some gems

SSH to root:

[~]# mkdir .gems
[~]# gem install gem_name -i ~/.gems

Temporarily assign GEM_HOME and GEM_PATH

[~]# export GEM_HOME=$HOME/.gems
[~]# export GEM_PATH=/usr/local/lib/ruby/gems/1.8:$GEM_HOME

Unpack gems to your app's vendor folder and require them correctly

Rails with automatically check to see if there is a frozen (or unpacked) gem in the vendor folder of an app before it looks for the default server gems folder.

So, to take control of your application:

Logout and start a new session or rake will not work.

[~]# cd rails_app
[~/rails_app]# rake freeze_gems

This will freeze the Rails version you downloaded.

To unpack/freeze other gems to the vendor folder, do the following:

[~]# cd vendor
[~/vendor]# gem unpack gem_name
[~/vendor]# gem unpack another_gem_name

Your Rails app will permanently run on these gems unless you delete the vendor folder.

Note: some gems need to be required manually (very rare though after Rails 1.1.0). Be sure to include the lib folder:

require 'RedCloth/lib/RedCloth'

Everything is now frozen.

(711 vote(s))
Not helpful

Comments (0)
Post a new comment
Full Name:
CAPTCHA Verification 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).