3

Ruby keeps segfaulting when using the Koala gem to talk over HTTP:

/Users/pawel/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:799: [BUG] Segmentation fault

I've tried the following:

  • Run which -a ruby which showed multiple Rubies via MacPorts. So I deleted those and running the same command again returns only /usr/bin/ruby
  • I've removed the MacPorts version of PostgreSQL and installed it with Homebrew instead (With MacPorts, it installs its own version of OpenSSL)
  • Running openssl version returns OpenSSL 1.0.0g 18 Jan 2012
  • I removed Ruby 1.9.3 from RVM and tried Luciano's method below which didn't work.
  • I've also tried reinstalling 1.9.3 from RVM and specifying --with-openssl-dir=/opt/local since which openssl returns /opt/local/bin/openssl
  • I've reinstalled RVM (It's now version 1.10.2 in /Users/pawel/.rvm/bin/rvm)
  • I've upgraded to Ruby 1.9.3-p125 and have also tried on 1.9.2
  • I've followed the instructions here: http://www.christopherirish.com/2011/09/02/ruby-1-9-2-segmentation-fault-and-openssl/ (which are my above steps, actually). I've also read Christopher's previous post here.
  • In my project directory when I run the following then I get the expected 0.:

    ruby -rubygems -e" require 'eventmachine'; require 'openssl' "; echo $?

  • I've tried to sudo port -f deactivate openssl but then when I try to start a Rails server I get Library not loaded: /opt/local/lib/libssl.1.0.0.dylib

I need some more ideas on what else I can try, or things I've missed.

Simpleton
  • 6,285
  • 11
  • 53
  • 87
  • I removed `~/.rvm` dir nad installed rvm, ruby and `openssl` package from rvm (`rvm pkg install openssl`) and all started to work fine – fl00r Feb 16 '12 at 20:26
  • You mean running `rvm implode`? How did your `rvm install ruby 1.9.3` flag look? – Simpleton Feb 16 '12 at 20:36
  • I didn't know about `implode`. I've removed rvm dir manualy `rm -rf ~/.rvm`, then install rvm again, then `rvm pkg install openssl`, `rvm pkg install iconv`, `rvm install 1.9.2 --with-openssl-dir=$rvm_path/usr --with-iconv-dir=$rvm_path/usr` (yes,It is about 1.9.2, but I don't think it makes difference) – fl00r Feb 16 '12 at 20:48
  • I have tried this before, and tried it again last night, to no avail. – Simpleton Feb 17 '12 at 08:57

3 Answers3

7

I'm also getting this same Segmentation Fault error, but I'm trying to list files on AWS-S3.

Edit:

This way worked for me:

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:$HOME/.rvm/bin
rvm remove 1.9.3 
rvm pkg install iconv
rvm pkg install openssl
rvm install ruby-1.9.3 --with-openssl-dir=~/.rvm/usr --with-iconv-dir=~/.rvm/usr
  • as @Simpleton said, I wrote a comment in the wrong place. Now I'm editing it with a response. ;-)
Simpleton
  • 6,285
  • 11
  • 53
  • 87
Luciano Costa
  • 3,492
  • 2
  • 16
  • 8
  • Thanks this worked for me after trying similar reinstalls. Something funny about your rvm install line, copy/pasting didn't work, maybe some special characters. Anyway, thanks. – Amala Jan 30 '12 at 17:09
  • @Luciano Still giving you the bounty because this answer will probably work for anyone without MacPorts/Homebrew conflicts. – Simpleton Feb 20 '12 at 11:04
  • On Lion I had to run ```export CC=/usr/bin/gcc``` before it would compile. Found via [Jeff Douglas](http://blog.jeffdouglas.com/2011/08/01/ruby-1-9-2-install-errors-with-mac-os-x-lion-and-rvm/) – Forrest Mar 14 '12 at 22:15
  • I've tried various other hints as well without success - the specific PATH settings that removed the ambivalence about which openssl to use seem to make the difference and worked for me. – patschiboy Apr 20 '12 at 02:36
  • 1
    i needed to update RVM using `rvm get head`, then this worked great! via [Delameko](http://stackoverflow.com/a/8007305/361609) – colllin Jan 15 '13 at 05:35
2

The problem seemed to be that Homebrew and MacPorts were conflicting, so I deleted MacPorts, removed all packages and the /opt/local/ directory. This caused some issue with the PG gem due to the PostgreSQL installation on Homebrew.

So I deleted the Postgres formula, then reinstalled it and ditto for the OpenSSL installation using Homebrew.

After that I imploded RVM and installed it and my Rubies again (not sure if this step was necessary) and finally it works.

Simpleton
  • 6,285
  • 11
  • 53
  • 87
0

I ran into this issue, too, but used a different solution. Here's the full stack trace of the error.

Here is the official bug report: http://bugs.ruby-lang.org/issues/6184 The responses below the stack trace were very helpful.

If you're using OS X's default openssl -> do like brew install openssl and build with installed openssl, then try again.

If you're using openssl that installed by user -> build with OS X default ssl and try again.

This sounded similar to an issue for me recently when the readline library installed in MacPorts broke a ruby installation. Running the following script on the broken ruby installation showed it was loading the MacPorts openssl lib

require 'net/https'
puts `lsof -p #{$$} | grep ssl | awk '{print $9}'`

(the output)

/Users/john/.rbenv/versions/1.9.3-p125/lib/ruby/1.9.1/x86_64-darwin11.2.0/openssl.bundle
/opt/local/lib/libssl.1.0.0.dylib

The solution was to temporarily move MacPorts out of /opt/local while installing ruby.

  1. Quit all processes that are accessing MacPorts files. You can see which ones are running with sudo lsof | grep /opt/local.
  2. sudo mv /opt/local /opt/localbak
  3. Open a new terminal, then compile and install Ruby
  4. sudo mv /opt/localbak /opt/local

After that, the ruby installation worked properly alongside MacPorts and did not load the libssl file from MacPorts.

Community
  • 1
  • 1
John Douthat
  • 40,711
  • 10
  • 69
  • 66