How to get OpenSSL in Ruby 1.9.3 working on OSX 10.7 (fixing the Segmentation Fault with Ruby OpenSSL)

Published by Rob on January 20th, 2012 - in Ruby

update – this needs to have a recent version of RVM – it works with rvm 1.10 but not with 1.6 – do an rvm update first.

When using the mighty cobweb web crawler on my OSX 10.7 with Ruby 1.9.3 I was getting a seg fault in net http:

net/http.rb:799: [BUG] Segmentation fault

A bit of googling and isolation in IRB showed that this can be caused when hitting HTTPS urls using net http.

I saw a few different solutions to the problem, primarily talking about Ruby 1.9.2.Surprisingly it took me a while to end up at the RVM documentation about the problem: https://rvm.beginrescueend.com/packages/openssl/. This didn’t quite work out of the box for me, so I used the solution in the following gist.

1 2 3
rvm pkg install openssl
rvm remove 1.9.3
rvm install 1.9.3 --with-openssl-dir=$rvm_path/usr --with-gcc=clang
view raw file1.sh This Gist is brought to you using Simple Gist Embed.

and now I can happily crawl https urls.

Related posts:

  1. Two tricks for getting Backbone.js to play well with Ruby on Rails
  2. Updating RubyGems in OSX 10.5.7
  3. The Book of Ruby By Huw Collingbourne
  4. Ruby File Generation
  5. Fixing”No backend servers available” running Vignette on Weblogic

2 Responses

  1. Yee-haw! I had a similar problem with Net::LDAP segfaulting after upgrading rails from 3.1.0 to 3.2.1 and ruby from 1.9.2 to 1.9.3. I could not find anyone on the ‘net with the same problem, but I did get as far as determining that it had to be an OpenSSL problem on my OSX Lion. Your steps above solved my problem. Thanks!

  2. [...] So, the failure was while doing a bundle install at the end of creating a new rails application, which’s new in rails (to me anyway. It’s been a while since I last looked into rails). Googling for ruby segfault in http.rb pointed towards issues with OpenSSL. Then I found this post that describes how to fix the issue: http://www.rojotek.com/blog/2012/01/20/how-to-get-openssl-in-ruby-1-9-3-working-on-osx-10-7-fixing-t… [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© Rob@Rojotek