Phusion white papers Phusion overview

How to fix the Ruby 1.9 HTTPS/Bundler segmentation fault on OS X Lion

By Hongli Lai on May 9th, 2012

If you’ve installed a gem bundle on OS X Lion the past few weeks then you may have seen the dreaded “[BUG] Segmentation fault” error, where Ruby sees to crash in the connect C function in http.rb. Upgrading to the latest Ruby 1.9.3 version (p194) doesn’t seem to help. Luckily someone has found a solution for this problem.

It turns out the segmentation fault is caused by an incompatibility between MacPort’s OpenSSL and RVM. MacPorts installs everything to /opt/local but RVM does not look for OpenSSL in /opt/local. We solved the problem by reinstalling Ruby 1.9.3 with the MacPorts OpenSSL, as follows.

First edit $HOME/.rvmrc and add:

export CFLAGS="-O2 -arch x86_64"
export LDFLAGS="-L/opt/local/lib"
export CPPFLAGS="-I/opt/local/include"

Then run:

sudo port install libyaml
rvm reinstall ruby-1.9.3 --with-openssl-dir=/opt/local --with-opt-dir=/opt/local
  • Claudio Poli

    I’m surprised someone chooses to still use MacPorts over Homebrew, it is just too good to pass up imo ;)

    Thanks for the hint, hopefully it will help someone else.

  • http://lightyearsoftware.com/ Steve Madsen

    I ran into this problem several months ago and switched to Homebrew to resolve it. I understand MacPorts’s effort to minimize compatibility issues by installing its own dependencies, but sometimes (as here), it creates more problems.

  • http://www.monaqasat.com Karim Helal

    We actually went back to MacPorts from Homebrew as we just found it easier to use. On that particular problem we however still have issues. After issuing the commands, we got the following error:

    ShishBook :: ~ » sudo port install libyaml
    Password:
    Warning: xcodebuild exists but failed to execute
    Warning: port definitions are more than two weeks old, consider using selfupdate
    Warning: Xcode does not appear to be installed; most ports will likely fail to build.
    —> Fetching archive for libyaml
    —> Attempting to fetch libyaml-0.1.4_0.darwin_11.x86_64.tbz2 from http://packages.macports.org/libyaml
    —> Fetching libyaml
    —> Attempting to fetch yaml-0.1.4.tar.gz from http://jog.id.distfiles.macports.org/macports/mpdistfiles/libyaml
    —> Verifying checksum(s) for libyaml
    —> Extracting libyaml
    —> Configuring libyaml
    —> Building libyaml
    —> Staging libyaml into destroot
    —> Installing libyaml @0.1.4_0
    —> Activating libyaml @0.1.4_0
    —> Cleaning libyaml
    ShishBook :: ~ » rvm reinstall ruby-1.9.3 –with-openssl-dir=/opt/local –with-opt-dir=/opt/local
    Removing /Users/khelal/.rvm/src/ruby-1.9.3-p125…
    Removing /Users/khelal/.rvm/rubies/ruby-1.9.3-p125…
    Removing ruby-1.9.3-p125 aliases…
    Removing ruby-1.9.3-p125 wrappers…
    Removing ruby-1.9.3-p125 environments…
    Removing ruby-1.9.3-p125 binaries…
    Fetching yaml-0.1.4.tar.gz to /Users/khelal/.rvm/archives
    Extracting yaml-0.1.4.tar.gz to /Users/khelal/.rvm/src
    Configuring yaml in /Users/khelal/.rvm/src/yaml-0.1.4.
    Compiling yaml in /Users/khelal/.rvm/src/yaml-0.1.4.
    Installing yaml to /Users/khelal/.rvm/usr
    Installing Ruby from source to: /Users/khelal/.rvm/rubies/ruby-1.9.3-p125, this may take a while depending on your cpu(s)…

    ruby-1.9.3-p125 – #fetching
    ruby-1.9.3-p125 – #extracting ruby-1.9.3-p125 to /Users/khelal/.rvm/src/ruby-1.9.3-p125
    ruby-1.9.3-p125 – #extracted to /Users/khelal/.rvm/src/ruby-1.9.3-p125
    ruby-1.9.3-p125 – #configuring
    ruby-1.9.3-p125 – #compiling
    Error running ‘make ‘, please read /Users/khelal/.rvm/log/ruby-1.9.3-p125/make.log
    There has been an error while running make. Halting the installation.

  • http://www.rubify.com Chardy

    Will this happen if I am using rbenv and brew? -Thanks.

  • LHM

    The following fixed it for me using rbenv and macports:

    CONFIGURE_OPTS=’–with-openssl-dir=/opt/local –with-opt-dir=/opt/local’ rbenv install 1.9.3-p194