Skip to content

Instantly share code, notes, and snippets.

@imathis
Created July 25, 2011 16:49
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save imathis/1104557 to your computer and use it in GitHub Desktop.
Save imathis/1104557 to your computer and use it in GitHub Desktop.
FIX for Lion's posix_spawn_ext.bundle: [BUG] Segmentation fault

The segfault problem with posix_spawn is indeed caused by Lion's compiler being LLVM and not GCC by default. However, when I installed RVM, the notes suggested that on Lion you need to add export CC=/usr/bin/gcc-4.2 to your shell startup file (.bashrc or .zshrc as appropriate). I did that, but it seems that's what caused problems: while ruby 1.9.2 needs you to use GCC to install it, using the same compiler for the gems apparently causes breakage.

First, you need to install XCode 4.x, which is now a free (though hefty!) download from the Mac App Store. Without that, you have no gcc, so you won't get anywhere ;-)

Next, what you need to do is clear out your rvm ruby and the associated gems (make sure you are cd'd into your octopress repository then do:

rvm remove ruby-1.9.2 --gems --archive

which will clear everything out so that you can start from scratch. Obviously, if you have other stuff you've installed for other purposes using RVM, be careful with this. If you previously had the export CC line in your shell file, remove it, source the script (or restart Terminal), and then check that CC is no longer set by doing:

echo $CC

If that returns a blank line, you've done it right. Now we're back with a clean slate.

Reinstall ruby, using gcc as the compiler temporarily:

CC=/usr/bin/gcc-4.2 rvm install ruby-1.9.2

After that, you should be able to

gem install bundler
bundle install

and all will be well!

@mattia
Copy link

mattia commented Feb 28, 2012

In Lion 10.7.3 and Xcode 4.3 (but I believe also in Xcode 4.2) gcc-4.2 is no longer available. A workaround is to install Xcode 4.3 from the App Store, install the Command Line Tools (Xcode -> Preferences -> Downloads -> Components).
When installed you have to set the Xcode environment for the command line this way:

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer

Remove the old version of ruby 1.9.2 (like before), and install with clang as compiler:

rvm install ruby-1.9.2 --with-gcc=clang

Now the bundle install will work and also your rake generate etc.

@dawnfriedland
Copy link

imathis,

Thank you for this! I followed the steps and it worked! (I am running Lion 10.7.3 and Xcode 4.1.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment