8

I am novice rails/terminal user and just did a fresh Lion install + Xcode after that.

Installed RVM but when I execute "gem install [any gem]" in terminal, I get this error:

/Users/[my user]/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/timeout.rb:60: [BUG] Segmentation fault
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.0.0]
Abort trap: 6

Can anyone help, please?

PS. I am using - and in the project I am working on, I must use ruby v1.8.7.

RickDT
  • 2,104
  • 1
  • 23
  • 25
rassom
  • 2,896
  • 5
  • 34
  • 45

3 Answers3

18

Make sure your rvm is up to date: rvm get latest

And then run this: rvm uninstall 1.8.7 && CC=/usr/bin/gcc-4.2 rvm install 1.8.7

Basically you must tell rvm which gcc compiler to use (CC=/usr/bin/gcc-4.2)

Then you should be able to install the pg gem as normal.

Andrew Nesbitt
  • 5,976
  • 1
  • 32
  • 36
  • 1
    Thanks very much, Andrew. Unfortunately, after following your instructions, I still get exactly the same error message. Any other ideas to try out? PS. Before trying your solution I executed this in terminal "export CC=/usr/bin/gcc-4.2" (from the solution in this thread: http://stackoverflow.com/questions/6170813/why-cant-i-install-rails-on-lion-using-rvm). Maybe that messed something up so your solution doesn't work? – rassom Jul 22 '11 at 13:23
  • This fixed it for me. @rassom, make sure that you're doing the uninstall phase as well. Ruby has to be recompiled for 'gem install' to work on Lion + 1.8.7 – RickDT Aug 09 '11 at 19:53
  • 3
    If you're on a fresh install of Lion+Xcode, you will not have /usr/bin/gcc-4.2 available. Install https://github.com/kennethreitz/osx-gcc-installer for a copy of gcc (recommended by `rvm requirements`) – Gabe Martin-Dempesy Jan 17 '12 at 17:05
  • For me, 'uninstall' was insufficient; I had to use Polo's 'remove' command instead. – M. Anthony Aiello Jan 23 '12 at 23:49
  • The reason that `rvm uninstall` can sometimes be insufficient is that that `rvm install` reuses the build directory without running `make clean`. You can either find the build directory and run it yourself, or `rvm remove` will completely delete it and download the tarball from scratch. – Jason Stirk Jan 04 '13 at 00:52
9

uninstall it with

rvm remove 1.8.7

then do the

CC=/usr/bin/gcc-4.2 rvm install 1.8.7
Polo Ornelas
  • 111
  • 2
  • Thanks, Polo - that solved it. Accepted Andrews answer as it was mostly my novice status not seeing that it was two seperate commands, but wish I could accept both of your answers. Thanks for taking the time to answer. Really appreciate it! :-) – rassom Jul 22 '11 at 21:22
4

In Mac OSX Lion (10.7), gcc-4.2 is not installed.

So you must download the installer (https://github.com/kennethreitz/osx-gcc-installer) and install it, then run

rvm uninstall 1.8.7 && CC=/usr/bin/gcc-4.2 rvm install 1.8.7
Shawn Chin
  • 84,080
  • 19
  • 162
  • 191
rc1021
  • 703
  • 1
  • 7
  • 16