Hpricot in rails

For some reason hpricot and rails on Dreamhost are not playing nice together. My app worked fine in mongrel on my home sever… and works fine with script/server from Dreamhost (although I’ve since found this is against the TOS). However, my app does not get loaded up through dispatch.fcgi.

The culprit?

require ‘hpricot’

If I comment that line from my config/environment.rb all is good in the world again. So there’s some issue with apache/FCGI and hpricot.

I’ve found lots of descriptions of the problem and attempted fixes, none of which have worked for me. Any other ideas out there??


Is this a custom gem installed in your $HOME? I don’t see hpricot among the stock gems so I assume it must be.

What variables do you have set in your shell environment? FastCGI doesn’t load any of your environment variables so you’ll have to set those in your environment.rb. Try something like:

ENV[‘GEM_PATH’] = ‘/home/me/gems’

Guessing here, but that seems likely based on your description…

Well, that Env Variable is not set in enviornment.rb BUT the console has no problem loading up hpricot…

RAILS_ENV=production ./script/console
Loading production environment.


=> []

If the console can do it, why shouldn’t the server? On the other hand, I do have a bunch of environment variables set in various places – maybe i’ll try adding them to my environment.rb file.

Still, what’s your take on the console deal?


On my site, hpricot stopped loading about a week ago.
I have no idea why, but this worked:

  • add the ENV[‘GEM_PATH’] line to environment.rb and
  • require the gem with the exact path:
    require “/home/#{username}/.gems/gems/hpricot-0.6/lib/hpricot”

I don’t think it’s an hpricot-specific thing but more likely Dreamhost’s sloppy implementation of rubygems. Or did any other local gem work for you?