Freeze all your ruby gems on a shared host

Things started to go downlhill when I had to check back on a previous article I had written about (Allowing full access to a sub directory in Apache Server) and my server would just hang!
Well, not a problem, let’s just try to hit the refresh key, hmmm, nothing. Ok, for good measure, let’s hit the button, just to be sure. Hmmm, still nothing.
Ok, let’s check out the logs, started from the apache logs.

[Tue Mar 28 21:04:31 2006] [error] [client 66.249.66.226] FastCGI: incomplete headers
(0 bytes) received from server “/home/psq/blog.nanorails.com/current/public/dispatch.fcgi”

Ok, yep, something’s wrong. Next, let’s hit the production.log. Nothing useful.

Next, a trick I learned before (aren’t you glad it is not your first time troubleshooting FastCGI?). Let’s call public/dispatch.fcgi directly:

/usr/local/lib/site_ruby/1.8/rubygems.rb:194:in `report_activate_error’:
    RubyGem version error: activerecord(1.13.2 not = 1.14.0) (Gem::LoadError)
    from /usr/local/lib/site_ruby/1.8/rubygems.rb:136:in `activate’
    from /usr/local/lib/site_ruby/1.8/rubygems.rb:162:in `activate’
    from /usr/local/lib/site_ruby/1.8/rubygems.rb:161:in `each’
    from /usr/local/lib/site_ruby/1.8/rubygems.rb:161:in `activate’
    from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:23:in `require’
    from ./../config/boot.rb:14
    from ./../config/environment.rb:8:in `require’
    from ./../config/environment.rb:8
    from ./dispatch.fcgi:21:in `require’
    from ./dispatch.fcgi:21

Ah ha! Bingo. What does it all mean, though?

It has been hard to miss that Rails 1.1 is not officially out. Yeahh!!! I wonder whether Dreamhost (aff) has maybe, just maybe, decided to upgrade.

gem list|grep rails

Ah ha! again. Yes, rails is is now 1.0 and 1.1. So I futz a little bit to try to freeze the gems manually, to not avail :(. So I go home, and fortunately, thanks to Capistrano, I have a full copy on my home machine! After doing a little reading, I figure the solution has to be:

rake freeze_gems

So first things first, I get home, rush to my machine, run the magic command, then run what was going to solve all the recent woes:

cap deploy -q

and hit the refresh button…
Duh! Still doesn’t work. Major Bummer!

Next step is to get a copy of all my gems (for typo):

 cd vendor/rails
 gem unpack activerecord
 gem unpack activesupport
 gem unpack actionpack
 gem unpack actionmailer
 gem unpack actionwebservice
 mv activerecord-1.13.2/ rails/
 mv actionmailer-1.1.5/ actionmailer
 mv actionpack-1.11.2/ actionpack
 mv actionwebservice-1.0.0/ actionwebservice
 mv activerecord-1.13.2/ activerecord
 mv activesupport-1.2.5/ activesupport

Your versions may vary depending on your install.

Then, committed everything, and redeployed.

and Ta Da! everything’s now back to normal! Phew…

The moral of the story, it that wasn’t clear already is:

Do not rely on the gems installed on your shared host!

Make sure your freeze all your gems

And I can worry on my own time to upgrade to rails 1.1 in my production environmment.

Update about 2 hours later:

Assuming you can run rake (which I couldn’t because of some broken dependency), an other method to lock down to rails 1.0 is to use:
rake freeze_edgeREVISION=3303

this assumes that’s you are using rails directly from svn already.

Update about 18h later:

An other solution is to lock down the versions of the gems you use in environment.rb using what suggested on Ruby On Rails Wiki. Thank you, Miles Barr for the tip!

Tags: , ,

6 Responses to “Freeze all your ruby gems on a shared host”

  1. robert March 28, 2006 at 10:03 pm #

    Hi, would it be possible for you to make a .tgz file of the vendor directory for download? I’m having trouble doing the above, as rake dies on dreamhost. :-(

  2. robert March 28, 2006 at 10:03 pm #

    actually, never mind, i managed to get it running. I’ve also uploaded the rails.zip file that contains all the necessary files at http://clarity.awakeheart.net/rails.zip

  3. Pascal March 28, 2006 at 10:03 pm #

    Glad to hear you got it running! And thank you for sharing the link to your rails directory.
    When even rake was dying, I knew it would not be a quick fix. Fortunately I still had a working setup. Having that zip would have helped turn 2 hours (including the drive home) into 10 minutes.

  4. Amit March 28, 2006 at 10:03 pm #

    hi My currently rails version is 2.0.2 and i want to freze my project to rasil 1.2.5. so please let me know how i would do this

  5. Anthony Ettinger March 28, 2006 at 10:03 pm #

    when I freeze gems, and run svn st, I get ”~” next to it.

    It appears something is amiss.

  6. Pascal March 28, 2006 at 10:03 pm #

    You may want to either add these to your .svnignore file, or actually add the gems to svn

1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|134|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208| buy cheap tenormin buy karela online purchase online without prescription nolvadex proscar uk where to buy no prescription needed secure online purchase risperdal no prescription cheapest accutane pills no prescription antibiotics online purchase indocin generic tablets buy herbal somaeurax and cost buy without a prescription nitroglycerinAccutane Online Doxycycline online Buy Cheap Lexapro Online No Prescription Prednisone Online payday loans online no checking account