Search code examples
rubygccrubygemssegmentation-faultrbenv

Ruby 1.8.6 `gem install` segfaults with "abort trap 6"


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)

Solution

  • 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.