ruby 2.0 rails gem install error “cannot load such file — openssl”

前端 未结 13 1278
难免孤独
难免孤独 2020-11-28 22:12

I am using osx 10.8.2 installed ruby 2.0 and.... got this when trying to run \"sudo gem install rails\"

$         


        
相关标签:
13条回答
  • 2020-11-28 23:05

    You have to install OpenSSL first and recompile ruby again:

    RVM:

    rvm pkg install openssl
    rvm reinstall ruby-2.0.0-p0 --with-gcc=gcc-4.7 --with-openssl-dir=$rvm_path/usr
    
    0 讨论(0)
  • 2020-11-28 23:06

    I fix this error for ruby 2.1.2 as follow.

    rvm pkg install openssl
    rvm reinstall ruby-2.1.2 --with-openssl-dir=$rvm_path/usr
    
    0 讨论(0)
  • 2020-11-28 23:07

    When installing ruby 2.0, it is possible that rubygems 2.0 installation did not complete ok, because of openssl. Make sure you provide a valid path to the openssl config file; you could:

    find . -type f -name "openssl.cnf"
    

    path is usually $HOME/.rvm/usr or $HOME/.rvm/usr/ssl

    Then

    [sudo] rvm reinstall ruby-2.0.0-p0 --with-openssl-dir=[openssl.cnf path] --verify-downloads 1
    

    Make sure rubygems installation complete successfully. Might be a better way to fix that path without reinstalling, but this should do it.

    0 讨论(0)
  • 2020-11-28 23:08

    If you are using ruby-install, it will take the same openssl argument as rvm:

    ruby-install ruby-2.0.0-p247 -- --with-openssl-dir=/usr/local/opt/openssl
    
    0 讨论(0)
  • 2020-11-28 23:14

    I had the same problem with the same OS version. I use rvm and followed the steps in this command:

    $ rvm requirements
    

    Following those instructions, I ran:

    $ brew update
    $ brew tap homebrew/dupes
    $ brew install bash curl git
    $ brew install autoconf automake apple-gcc42 libtool pkg-config openssl readline libyaml sqlite libxml2 libxslt libksba
    
    0 讨论(0)
  • 2020-11-28 23:15

    On OSX, with rbenv and homebrew, the following worked for me:

    brew install openssl
    CONFIGURE_OPTS=--with-openssl-dir=$(brew --prefix openssl) rbenv install whatever-ruby-version
    
    0 讨论(0)
提交回复
热议问题