Saturday, December 4, 2010

Installing curb gem on Mac OS X 10.6 (Snow Leopard)

If you have previously installed curl with something like:

    sudo port install curl +ssl

and then try to install the curb gem like:

    sudo gem install curb

and you find yourself getting an error that looks something like this:


In file included from /opt/local/include/curl/curl.h:44,
from curb.h:12,
from curb.c:8:
/opt/local/include/curl/curlrules.h:144: error: size of array ‘__curl_rule_01__’ is negative
/opt/local/include/curl/curlrules.h:154: error: size of array ‘__curl_rule_02__’ is negative
lipo: can't open input file: /var/folders/wX/wX64Cb+PGjG-EXuklO+I+k+++TI/-Tmp-//ccKIrqTY.out (No such file or directory)
make: *** [curb.o] Error 1

Then, I think I have a solution for you. Change your curb install command to this instead:

    sudo env ARCHFLAGS="-Os -arch x86_64 -fno-common" gem install curb

It seems a number of people on the web suggest re-installing curl as a universal binary using something like:

    sudo port install zlib +universal
sudo port upgrade --enforce-variants openssl +universal
sudo port install curl +universal

I do not like this approach. The original problem is that you installed an x86_64 version of curl (which is the default, as it should be) but you are trying to install a universal version of curb (which is unfortunately the default). Instead of re-installing curl to be universal, which is wasteful and takes forever, install curb using the x86_64 flags to build it. This is what you want, it works, and it only takes a few seconds.

5 comments:

Steven Noble said...

Is it possible to write this into a Gemfile? I've successfully updated my systemwide gem but have a hell of a time updating the local version of the gem that bundler uses.

Steven Noble said...

I have the answer:

env ARCHFLAGS="-Os -arch x86_64 -fno-common" bundle install

scottwb said...

Nice - thanks for that, Steven. I haven't hit this hurdle yet, since I am not using curl in a bundle yet - only system wide. But I was planning to do so next time I setup my mac from scratch...so your tip will definitely come in handy.

humbroll said...

thanks~!
very helpful post. :)

Anonymous said...

Great! Thanks for the tip.