2

I can't install any gems on my fresh rbenv-installed Ruby 1.8.6 on Mountain Lion. gem install segfaults and the shell prints "Abort trap: 6":

$ RUBYLIB= RUBYOPT= bash

$ gem install --verbose bundler
  GET http://rubygems.org/latest_specs.4.8.gz
  302 Moved Temporarily
  GET http://production.s3.rubygems.org/latest_specs.4.8.gz
  304 Not Modified
  Installing gem bundler-1.3.5
  Abort trap: 6

There are similar issues reported but the answer to all of them is that they need to use non-Apple GCC 4.2 to build such an old version of Ruby. That doesn't apply to me, since I've installed GCC with brew install apple-gcc42 and rbenv install process picked that up, as evident below:

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.8.6 (2010-09-02 patchlevel 420) [i686-darwin12.3.0]
  - INSTALLATION DIRECTORY: /Users/mislav/.rbenv/versions/1.8.6-p420/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /Users/mislav/.rbenv/versions/1.8.6-p420/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/mislav/.rbenv/versions/1.8.6-p420/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-darwin-12
  - GEM PATHS:
     - /Users/mislav/.rbenv/versions/1.8.6-p420/lib/ruby/gems/1.8
     - /Users/mislav/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - "gem" => "--no-ri --no-rdoc"
  - REMOTE SOURCES:
     - http://rubygems.org/

$ ruby -rrbconfig -e 'puts RbConfig::CONFIG["configure_args"]'
  '--prefix=/Users/mislav/.rbenv/versions/1.8.6-p420'
  'CC=/usr/local/bin/gcc-4.2'
  'CFLAGS=  -Wno-error=shorten-64-to-32'
  'LDFLAGS=-L'\\''/Users/mislav/.rbenv/versions/1.8.6-p420/lib'\\'' '
  'CPPFLAGS=-I'\\''/Users/mislav/.rbenv/versions/1.8.6-p420/include'\\'' '

$ /usr/local/bin/gcc-4.2 --version
  i686-apple-darwin11-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Community
  • 1
  • 1
mislav
  • 14,919
  • 8
  • 47
  • 63

3 Answers3

1

The only difference I can see at a glance is that I installed gcc-4.2 into /usr/bin and you used /usr/local/bin. That shouldn't make a difference, but I suppose it's possible that some Makefile hardcoded /usr/bin (which is more common - I guess?) for gcc.

Since you mentioned that you used Homebrew to install gcc-4.2, I'll also add that I used a manual method, following these instructions: http://caiustheory.com/install-gcc-421-apple-build-56663-with-xcode-42. Again I don't think that should make a difference, but you never know.

mislav
  • 14,919
  • 8
  • 47
  • 63
Telemachus
  • 19,459
  • 7
  • 57
  • 79
  • Yep, compiling it from source did it. That means that Homebrew-distributed apple-gcc is broken for my version of OS X and I'm going to report it. – mislav Apr 14 '13 at 16:48
  • Hi, I believe my situation is the same as @mislav and I understand this answer, however I'm unsure how to fix the issue. I have a gcc in `/usr/bin/gcc` and also the one installed using homebrew. Do I need to uninstall the homebrew version, then reinstall using the caiustheory.com link? And if so will this mess up anything on my Mac OS Sierra? I understand the issue just unsure as the best way to fix it. thanks – FireDragon Feb 22 '17 at 09:55
  • 1
    @FireDragon I'm sorry, but I'm not sure what to recommend. I don't use Ruby much anymore, and I worry that in four years a lot may have changed. I don't even know if the Caius method works any longer on current Macs. It may be best to open a new question: specify what version of Ruby you want, what tools you're using, etc. Even if you refer to this question, things are likely different now. – Telemachus Feb 22 '17 at 14:58
0

It's probably the case that newer versions of rubygems won't work on versions of Ruby 1.8.6 and prior.

You could always try slimgems as an alternative. That's a fork of the 1.3.x series rubygems system that was patched for bugs, not features.

tadman
  • 208,517
  • 23
  • 234
  • 262
  • I'm not running newer versions of Rubygems. And unless it's compiling a native extension, there's no code in Rubygems that should segfault. This smells like a broken Ruby build. – mislav Apr 05 '13 at 17:29
0

Prob the version of OS X. Apple changed their compiler in the new OS X and Xcode.' Where's gcc installed? Try running which gcc.

jahrichie
  • 1,215
  • 3
  • 17
  • 26
  • I'm aware that Apple switched `gcc` to use their LLVM compiler and that older Rubies don't work with it. That's why I stressed out that I'm using `apple-gcc42` from Homebrew that is their previous version of gcc which is not LLVM-based. – mislav Apr 07 '13 at 11:38