简体   繁体   中英

Segmentation fault when I run rails S (cant compile nokogiri)

I have been in configuration hell for two days and I have tried just about everything on Stack Overflow to fix it. I feel like some of the stuff I have tried may have made things worse. I was using RVM, then I tried using rbenv, and now I am back to using RVM again. I am not sure if there are remnants of rbenv that are causing this or what but I followed the instructions to remove it completely.

The error I am getting currently is here:

https://gist.github.com/EvanTedesco/d4288cfb1f8dfc5a1e03

ruby -v:

ruby 1.9.3p547 (2014-05-14 revision 45962) [x86_64-darwin13.4.0] 

rails -v:

Rails 3.2.19

xcode-select -p:

/Library/Developer/CommandLineTools

gem env:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.4.3
  - RUBY VERSION: 2.1.5 (2014-11-13 patchlevel 273) [x86_64-darwin14.0]
  - INSTALLATION DIRECTORY: /Users/acumendigital/.rvm/gems/ruby-2.1.5
  - RUBY EXECUTABLE: /Users/acumendigital/.rvm/rubies/ruby-2.1.5/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/acumendigital/.rvm/gems/ruby-2.1.5/bin
  - SPEC CACHE DIRECTORY: /Users/acumendigital/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-14
  - GEM PATHS:
     - /Users/acumendigital/.rvm/gems/ruby-2.1.5
     - /Users/acumendigital/.rvm/gems/ruby-2.1.5@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["https://rubygems.org/", "http://rubygems.org"]
  - REMOTE SOURCES:
     - https://rubygems.org/
     - http://rubygems.org
  - SHELL PATH:
     - /Users/acumendigital/.rvm/gems/ruby-2.1.5/bin
     - /Users/acumendigital/.rvm/gems/ruby-2.1.5@global/bin
     - /Users/acumendigital/.rvm/rubies/ruby-2.1.5/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /user/sbin
     - /sbin
     - /user/local/bin
     - /usr/local/git/bin
     - /Users/acumendigital/.gem/ruby/1.8/bin
     - /opt/nginx/sbin
     - /Users/acumendigital/.rvm/bin

rvm info:

ruby-1.9.3-p547@ums:

  system:
    uname:       "Darwin Evans-MacBook-Pro.local 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64"
    system:      "osx/10.9/x86_64"
    bash:        "/bin/bash => GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)"
    zsh:         "/bin/zsh => zsh 5.0.2 (x86_64-apple-darwin13.0)"

  rvm:
    version:      "rvm 1.26.3 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
    updated:      "8 minutes 33 seconds ago"
    path:         "/Users/acumendigital/.rvm"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.3p547"
    date:         "2014-05-14"
    platform:     "x86_64-darwin13.4.0"
    patchlevel:   "2014-05-14 revision 45962"
    full_version: "ruby 1.9.3p547 (2014-05-14 revision 45962) [x86_64-darwin13.4.0]"

  homes:
    gem:          "/Users/acumendigital/.rvm/gems/ruby-1.9.3-p547@ums"
    ruby:         "/Users/acumendigital/.rvm/rubies/ruby-1.9.3-p547"

  binaries:
    ruby:         "/Users/acumendigital/.rvm/rubies/ruby-1.9.3-p547/bin/ruby"
    irb:          "/Users/acumendigital/.rvm/rubies/ruby-1.9.3-p547/bin/irb"
    gem:          "/Users/acumendigital/.rvm/rubies/ruby-1.9.3-p547/bin/gem"
    rake:         "/Users/acumendigital/.rvm/rubies/ruby-1.9.3-p547/bin/rake"

  environment:
    PATH:         "/Users/acumendigital/.rvm/gems/ruby-1.9.3-p547@ums/bin:/Users/acumendigital/.rvm/gems/ruby-1.9.3-p547@global/bin:/Users/acumendigital/.rvm/rubies/ruby-1.9.3-p547/bin:/Users/acumendigital/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/user/sbin:/sbin:/user/local/bin:/usr/local/git/bin:/Users/acumendigital/.gem/ruby/1.8/bin:/opt/nginx/sbin"
    GEM_HOME:     "/Users/acumendigital/.rvm/gems/ruby-1.9.3-p547@ums"
    GEM_PATH:     "/Users/acumendigital/.rvm/gems/ruby-1.9.3-p547@ums:/Users/acumendigital/.rvm/gems/ruby-1.9.3-p547@global"
    MY_RUBY_HOME: "/Users/acumendigital/.rvm/rubies/ruby-1.9.3-p547"
    IRBRC:        "/Users/acumendigital/.rvm/rubies/ruby-1.9.3-p547/.irbrc"
    RUBYOPT:      ""
    gemset:       "ums"

Honestly I have no Idea what else to try. Any help is appreciated greatly.

Notice that your gem env says you're running Ruby 2.1.5:

- RUBY VERSION: 2.1.5 (2014-11-13 patchlevel 273) [x86_64-darwin14.0]

while your ruby -v shows 1.9.3:

ruby 1.9.3p547 (2014-05-14 revision 45962) [x86_64-darwin13.4.0] 

That tells me your system is really mixed up.

First, capture the list of current gems in your Ruby environment by running:

gem list --no-version > ~/gem_list

That stores the list of gems currently installed without version numbers in the "gem_list" file at your user's home directory.

Next, I'd recommend doing an rvm implode , then exit from your shell and reopen a terminal window. Run

grep rvm ~/.bash_profile

and look for lines where RVM is being initialized. Delete those from your ~/.bash_profile.

Then, look for lines mentioning rbenv in the same file:

grep rbenv ~/.bash_profile

and remove them.

Then reinstall RVM by following the directions at http://rvm.io/rvm/install . Read through the directions carefully and follow the directions for doing a single-user installation. Once RVM finishes installing, read the text it outputs and do what it says about setting up your ~/.bash_profile.

At that point you should be able to install a Ruby using:

rvm install 2.1.5

Once that finishes run:

rvm use 2.1.5 --default

At that point RVM and your environment should be happy and you can reinstall gems. Run:

xargs gem install --conservative < ~/gem_list

Gem should chug away, and reinstall the gems you'd previously installed. Eventually it'll stop and if everything looks good you can delete the list of gems using:

rm ~/gem_list

Note: You are running a Mac OS X machine, and Apple preinstalls Ruby on it. Never use sudo to install any gems or try to remove the Ruby Apple installs. They put it there to make it possible to run some code, and it's OK for you to run things with it too, but treat it as belonging to the system. That's why we use RVM, to have a version of Ruby we can safely mess with, without running the risk of breaking the default one.

There are many tutorials and blogs on the internet purporting to tell us how to install RVM on our machines, but most of them are out of date, so ignore them. Instead, follow what the RVM authors wrote on their website. The installation page says:

External tutorials

Note that that any outside tutorials are NOT supported whether they work or not. Tutorials are great, however we have spent massive amounts of man hours debugging the installation process. Please use the install process(es) from this site only, as this is the only supported installation types and methods.

So I tried the steps provided by the tin man and I was still getting the seg fault. I finally got access to a senior dev and he determined that the problem was that my open ssl was not configured properly. I fixed the issue with

brew link --force openssl

then I removed and reinstalled the gemsets and rubies. All good now. Thank you to everyone who took time to answer my question and I hope this helps someone else. Special thanks to the Tin Man for taking the time to write that detailed response.

I also noticed that when I was bundling that I was getting

Your bundle is complete!
It was installed into ./vendor/bundle

so I deleted ./vendor/bundle with

rm -rf ./vendor/bundle

and rebundled.

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