Monday, December 14, 2009

installing curb on ubuntu 8.1

i switched over from Net::HTTP to the curb gem (curl bindings for ruby) so i could take advantage of the performance gains (TBD) and that it keeps connections open by default.

on my local os x machine, i just ran:

sudo gem install curb

and everything worked fine. however, when deploying to our dev ubuntu box, it was not as smooth a process. when running gem install, i got the following error.

Building native extensions. This could take a while...
ERROR: Error installing curb:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb install curb
"-fno-strict-aliasing -g -g -O2 -fPIC $(cflags)"
checking for curl-config... no
checking for main() in -lcurl... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby1.8
--with-curl-dir
--without-curl-dir
--with-curl-include
--without-curl-include=${curl-dir}/include
--with-curl-lib
--without-curl-lib=${curl-dir}/lib
--with-curllib
--without-curllib
extconf.rb:19: Can't find libcurl or curl/curl.h (RuntimeError)

Try passing --with-curl-dir or --with-curl-lib and --with-curl-include
options to extconf.


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

after some googling, i determined that i probably needed the libcurl4-openssl-dev package, so i ran the following:

sudo apt-get install libcurl4-openssl-dev

that resulted in:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libidn11-dev libldap-2.4-2 libldap2-dev pkg-config
Suggested packages:
libcurl3-dbg
The following NEW packages will be installed:
libcurl4-openssl-dev libidn11-dev libldap2-dev pkg-config
The following packages will be upgraded:
libldap-2.4-2
1 upgraded, 4 newly installed, 0 to remove and 25 not upgraded.
Need to get 1115kB/2678kB of archives.
After this operation, 7115kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Err http://archive.ubuntu.com intrepid-updates/main libldap-2.4-2 2.4.11-0ubuntu6.1
404 Not Found [IP: 91.189.88.30 80]
Err http://archive.ubuntu.com intrepid-updates/main libldap2-dev 2.4.11-0ubuntu6.1
404 Not Found [IP: 91.189.88.30 80]
Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/o/openldap/libldap-2.4-2_2.4.11-0ubuntu6.1_amd64.deb 404 Not Found [IP: 91.189.88.30 80]
Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/o/openldap/libldap2-dev_2.4.11-0ubuntu6.1_amd64.deb 404 Not Found [IP: 91.189.88.30 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

as it turned out, my sources were out of date and when apt-get went looking for the libldap2 packages it needed, they were not there. so i ran:

sudo apt-get update

it updated my sources and i was able to install the libcurl4-openssl-dev package and succesfully install the curb gem. maybe that will help somebody out there.