Stopping Curb From Segfaulting

While trying to get the curb gem up and running using Ruby 1.8.7p174, I kept getting segmentation faults. I Google’d around and really wasn’t able to come up with much other than lots of people saying not to use ports here. Since I don’t use Mac Ports, I use Homebrew, I figured this wasn’t an issue. I had also recently installed the latest XCode so I incorrectly assumed there was no issue there either. (Note: I am running on a freshly upgraded version of Mac OS X Snow Leopard).

Since everything built correctly, I just assumed it would work correctly. Here it is obviously not doing so.

ruby-1.8.7-p174 >   require 'curb'
/Users/elubow/.rvm/gems/ruby-1.8.7-p174/gems/curb-0.7.7.1/lib/curb_core.bundle: [BUG] Segmentation fault
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.4.0]
Abort trap

So I narrowed it down to what I believe is an issue with the curl headers. The solution is to install a new curl library. Since I wanted to do it the Homebrew way, and Homebrew doesn’t have curl by default, here is what I did.

Copy the Homebrew Formula code from http://github.com/adamv/homebrew/blob/duplicates/Library/Formula/curl.rb into a file named curl.rb in your formula directory (mine is /usr/local/Library/Formula/). You should then be able to:

elubow@beacon tmp$ brew install curl
==> Downloading http://curl.haxx.se/download/curl-7.21.0.tar.bz2
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/curl/7.21.0 --disable-debug --disable-dependency-track
==> make install
/usr/local/Cellar/curl/7.21.0: 72 files, 1.8M, built in 3.6 minutes

Don’t forget to logout and log back into the shell so the new version of curl is available:

$ curl --version
curl 7.21.0 (x86_64-apple-darwin10.4.0) libcurl/7.21.0 OpenSSL/0.9.8l zlib/1.2.3 libssh2/1.2.2
Protocols: dict file ftp ftps http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
Features: IPv6 Largefile NTLM SSL libz

Now you have to uninstall and reinstall the curb gem. The easiest way that I found (since I have bundler installed) was to do bundle show curb to find out where the gem is located. I removed the directory and reran bundle install (or gem install curb if you don’t have bundler).

Because I am using rvm (Ruby Version Manager), I actually encountered this issue with 1.9.1p378 as well. This fixed the issue for both versions.

Posted in Ruby. Tags: , . 1 Comment »
  • unimatrixZxero

    Yeah, this solved my problem. I had another little caveat though. I had MAMP installed and it has it's own version of curl. Which was in my path for connivence, ironically as it turns out.