Install Mongrel & Hpricot Under Ubuntu

When­ever I do a fresh install of Ubuntu, and I’m set­ting up Ruby, Rails, I always run into the same prob­lem with a hand­ful of gems (such as Mon­grel & Hpri­cot). This is how things usu­ally go down:

matt@thinkpad:~$ sudo gem install hpricot
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
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:1
Gem files will remain installed in
/usr/lib/ruby/gems/1.8/gems/hpricot-0.6 for inspection.
Results logged to
/usr/lib/ruby/gems/1.8/gems/hpricot-0.6/ext/hpricot_scan/gem_make.out

Now what? The main prob­lem here is that Hpri­cot and Mon­grel both con­tain some C code that needs to be com­piled. In order to fix this, you’ll need to install the Ruby & C devel­op­ment libraries for Ubuntu. To do that, just fire up Ter­mi­nal and enter:

sudo apt-get install ruby1.8-dev linux-libc-dev libc6-dev

You should now be able to install Hpri­cot, Mon­grel, or any other gem that requires you to build some C. It’s that easy!

Tags: , , ,

4 Responses to “Install Mongrel & Hpricot Under Ubuntu”

  1. albertito says:

    Hi,

    In Fedora 9, it must be instal­lled like that:

    su
    "password root"
    yum install ruby-devel
    gem install hpricot

    Bye!! ;)

  2. Roy says:

    This works just fine!!! Thanks!!!

  3. Simone says:

    Didn’t know how to approach that error mes­sage… but google let me dis­cover your beau­ti­ful site.
    Thank you very much :)

  4. Joris says:

    Awe­some! Worked like charm!=)

Leave a Reply