views:

461

answers:

1

HELP!! I need to bundle a gem otherwise a published client's site will stay dead

    MacBook-Pros-MacBook-Pro:pn 
macbookpro$ sudo ruby script/generate sanitize
Missing the Rails 2.3.5 gem. Please `gem install -v=2.3.5 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.
+3  A: 

You could manually install the gem on the machine as the message tells you to, but since you're asking how to bundle the gem, that's probably not what you're looking for.

To bundle the Rails gems run the following on a machine that has the gems installed (probably your development machine):

rake rails:freeze:gems

This will unpack the Rails gems into vendor/rails. Then it's a matter of adding and commiting the gems.

To freeze/vendor all the gems required by your application (as defined in environment.rb):

rake gems:unpack:dependencies

If you use gems like Nokogiri that contains code which needs to be compiled for the environment it's running on, you have to a little more. After vendoring it, run

rake gems:build

and that should do it for you. Note, this last step needs to be run on the machine where the application needs to be run - in this case you can't just rely on doing it locally and committing your changes like you can with pure Ruby gems.

See http://reborg.tumblr.com/post/99668398/rails-gems-unpack-native for more details.

Jakob S
Thanks for your answer, this works, the gem now exists in /vendor/gemsBut when I try it on nokogiri gem it returned:`gem_original_require': no such file to load -- nokogiri/nokogiri (MissingSourceFile)I did it by:gem install nokogirirake rails:freeze GEM=nokogirithen,gem uninstall nokogiri (to test out if rails app could use the frozen gem)Is this not working with nokogiri?
jaycode
I added some explanation of how it works with gems like Nokogiri.
Jakob S