Installing Hpricot from Ruby Gems errors out

on Tuesday 31st March, 2009 Gabe speculated thusly…

I was recently trying to get a Ruby script working on Ubuntu. This script required Hpricot and using Ruby Gems to install Hpricot always resulted in an error:

 gem install hpricot --remote
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions into the /var/lib/gems/1.8 directory.
gabriel@windsor-telecom-2874:~/Music$ sudo gem install hpricot --remote
Building native extensions.  This could take a while...
ERROR:  Error installing hpricot:
	ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb install hpricot --remote
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
	from extconf.rb:1

Gem files will remain installed in /var/lib/gems/1.8/gems/hpricot-0.7 for inspection.
Results logged to /var/lib/gems/1.8/gems/hpricot-0.7/ext/hpricot_scan/gem_make.out

The answer was simple:
sudo aptitude install ruby-dev

Just install the Ruby Dev package, this will also allow you to install lots of other gems such as SQLite3, etc.

One Response to “Installing Hpricot from Ruby Gems errors out”

  1. Kevin Says:

    This saved me alot of time, thanks!

Leave a Reply