简体   繁体   中英

gem install raises segmentation fault with ruby 1.8.7, rbenv and no other local gems

I've got the old project to maintain on ruby 1.8.7, but I can't install bundle because there's no bundler installed for it currently and trying gem install bundler raises Segmentation fault. In fact it doesn't depend on gem, gem install <any gem> has the same result.

A few hours of googling had no effect, so here are the details:

$ gem install bundler
/home/marat/.rbenv/versions/1.8.7-p352/lib/ruby/1.8/timeout.rb:60: [BUG] Segmentation fault
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
Aborted

Environment details:

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.6.2
  - RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/marat/.rbenv/versions/1.8.7-p352/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /home/marat/.rbenv/versions/1.8.7-p352/bin/ruby
  - EXECUTABLE DIRECTORY: /home/marat/.rbenv/versions/1.8.7-p352/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/marat/.rbenv/versions/1.8.7-p352/lib/ruby/gems/1.8
     - /home/marat/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

No local gems currently:

$ gem list

*** LOCAL GEMS ***

Any ideas?

This is likely an OpenSSL problem. You can run:

CONFIGURE_OPTS="--with-openssl-dir=/opt/local" rbenv install 1.8.7

This will give you a clean install of Ruby 1.8.7 with the correct OpenSSL information. You may want to do rbenv uninstall first.

Update:

Another way to tackle this is to change source 'https://rubygems.org' to source 'http://rubygems.org' in your Gemfile.

My guess is that you are trying to install latest version of bundler that does not support ruby 1.8.7(refs here ). Try to install bundler version 1.7.3 or lower. Example: gem install bundler -v=1.17.3

Using older version of gcc helped me. Here're the steps I took to resolve the issue in my case:

Add repositories containing older versions of gcc for Ubuntu 16.04 and install it:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt install gcc-4.4

Build project using older gcc:

rbenv uninstall 1.8.7-p352
CC=/usr/bin/gcc-4.4 rbenv install 1.8.7-p352
CC=/usr/bin/gcc-4.4 rbenv local 1.8.7-p352

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM