Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I install Rails on Lion using RVM?

I'm running into issues trying to install Rails on OS X Lion using RVM.

So far, I have done the following:

  1. Installed Mac OS X Lion Version 10.7 (Build 11A459e).
  2. Installed XCode 4.1 Developer Preview 5.
  3. Installed RVM.
  4. Installed a 1.8.7 version of Ruby via RVM using the command rvm install 1.8.7. Note: I need to be using 1.8.7 and not 1.9.2.
  5. Switched to the 1.8.7 version of Ruby using the command rvm 1.8.7.
  6. Created a new gemset using the command rvm gemset create rails3.
  7. Switched to the new gemset using the command rvm use 1.8.7@rails3.
  8. To install Rails I ran the command gem install rails but I got the following error:

    /Users/m/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/timeout.rb:60: [BUG] Segmentation fault

The same error happens when trying to run any gem command so I don't think it's really a problem with Rails.

Judging by the links below, I don't seem to be the only person having this issue:

http://twitter.com/#!/pingles/status/66261101351927809 and https://github.com/carlhuda/bundler/issues/1058

like image 670
Michael Jerome Avatar asked May 29 '11 22:05

Michael Jerome


9 Answers

Fixed it!

The answer was actually on one of the links I posted above. Before installing a version of ruby (rvm install 1.8.7) I needed to run "export CC=/usr/bin/gcc-4.2". With that in place, everything ran smoothly.

If you don't want to have CC permanently exported, you can do CC=/usr/bin/gcc-4.2 rvm install 1.8.7

If you have already installed ruby 1.8.7. Just do CC=/usr/bin/gcc-4.2 rvm reinstall 1.8.7

like image 116
Michael Jerome Avatar answered Oct 13 '22 06:10

Michael Jerome


If you have installed Xcode 4.2, it actually doesn't install non-LLVM gcc anymore, so you have to add it. For some reason downgrading to 4.1 after you've installed 4.2 doesn't work correctly (at least it didn't for me and others have had similar issues).

After quite a bit of thrashing, this is what finally worked for me:

  1. Install Xcode 4.2 from App Store
  2. Install darwin gcc using the OSX gcc installer
  3. Install REE making sure you remove any vestiges of previous attempts:

Close any open terminal windows, open a fresh one and

rvm remove ree
export CC=/usr/bin/gcc-4.2
rvm install ree

This worked for me with rvm 1.8.6, OS X 10.7.2 and gcc-4.2 version 4.2.1 (Apple build 5666).

If you have already installed Xcode 4.1, resist the urge to upgrade to 4.2 and you should be okay.

like image 45
Matt Sanders Avatar answered Oct 13 '22 04:10

Matt Sanders


If that still doesn't work add --force. So this becomes:

CC=/usr/bin/gcc-4.2 rvm install ruby-1.8.7 --force

like image 34
Hans verschooten Avatar answered Oct 13 '22 06:10

Hans verschooten


Make sure that you remove 1.8.7 if you already installed it before using "export CC=/usr/bin/gcc-4.2" by doing "rvm remove 1.8.7"

like image 37
HeroicEric Avatar answered Oct 13 '22 05:10

HeroicEric


I had the same issue on my system. I installed the Xcode command line tools from Apple which ships with LLVM compiler and without an LLVM free one.

Ruby 1.8.7 won't work with an LLVM compiler not even with CC=clang, so installing an LLVM free gcc solves the problem.

There are multiple options listed here:

https://github.com/mxcl/homebrew/wiki/Custom-GCC-and-cross-compilers

Long story short, install GCC v4.2 with Homebrew:

brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb

and then install ruby 1.8.7:

CC=gcc-4.2 rvm install 1.8.7
like image 41
KARASZI István Avatar answered Oct 13 '22 05:10

KARASZI István


Check which version of gcc you have like this:

ls -Al `which gcc-4.2`

I followed the instructions here: http://robots.thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion

brew update
brew tap homebrew/dupes
brew install apple-gcc42

Then reinstall:

Check again what your path to gcc is (to use for CC=):

ls -Al `which gcc-4.2`

(optional) You can set this in your .bashrc for example:

export CC=/usr/bin/gcc-4.2

(optional) remove any old version of ruby

rvm remove 1.8.7

Then:

CC=/usr/local/bin/gcc-4.2 rvm --verify-downloads 1 reinstall 1.8.7-p357 --without-tcl --without-tk 

or if you have set CC in your profile

rvm --verify-downloads 1 reinstall 1.8.7-p357 --without-tcl --without-tk 

Note the flags on the rvm install. I had trouble verifying the checksum on the ftp server and some problems with tck and what not. You may be able to omit those flags.

Also: you might need to remove an old version of your gemset:

rvm gemset delete <gemset>

Then

gem install bundler
bundle install

Hope this helps.

like image 40
Rimian Avatar answered Oct 13 '22 04:10

Rimian


Using macport and ruby-1.9.x version. I did successfully install rails with ruby gem.

like image 32
Henry Kim Avatar answered Oct 13 '22 05:10

Henry Kim


Instead of "export CC=/usr/bin/gcc-4.2" do "export CC=gcc" (xCode 4.2.x should be installed).

like image 42
xpepermint Avatar answered Oct 13 '22 06:10

xpepermint


I have same problem only for arch x86_64, when I comment line in my ~/.rvmrc

rvm_archflags="-arch x86_64"

Open a new terminal and tried to install ruby-1.8.7 again

rvm install 1.8.7

It was successful.

like image 24
Michael Nikitochkin Avatar answered Oct 13 '22 05:10

Michael Nikitochkin