gem安装失败,openssl失败

Mos*_*ano 58 ruby macos openssl rubygems cocoapods

我试图在我的OSX Mountain Lion上安装cocoapods(http://cocoapods.org/).

 moshe-mbp:~ moshem$ gem install cocoapods
 ERROR:  Could not find a valid gem 'cocoapods' (>= 0), here is why:
      Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0      state=SSLv3 read server key exchange B: bad ecpoint (https://rubygems.org/latest_specs.4.8.gz)
Run Code Online (Sandbox Code Playgroud)

我先试过

 rvm reinstall all --force
Run Code Online (Sandbox Code Playgroud)

然后我试了

 brew upgrade openssl

    ==> Upgrading openssl
    ==> Downloading http://openssl.org/source/openssl-1.0.1e.tar.gz
    Already downloaded: /Library/Caches/Homebrew/openssl-1.0.1e.tar.gz
    ==> perl ./Configure --prefix=/usr/local/Cellar/openssl/1.0.1e --openssldir=/usr/local/etc/openssl zlib-dynamic shared d
    ==> make
    ==> make test
    ==> make install MANDIR=/usr/local/Cellar/openssl/1.0.1e/share/man MANSUFFIX=ssl
    ==> Caveats
    To install updated CA certs from Mozilla.org:

        brew install curl-ca-bundle

    This formula is keg-only: so it was not symlinked into /usr/local.

    Mac OS X already provides this software and installing another version in
    parallel can cause all kinds of trouble.

    The OpenSSL provided by OS X is too old for some software.

    Generally there are no consequences of this for you. If you build your
    own software and it requires this formula, you'll need to add to your
    build variables:

        LDFLAGS:  -L/usr/local/opt/openssl/lib
        CPPFLAGS: -I/usr/local/opt/openssl/include

    ==> Summary
      /usr/local/Cellar/openssl/1.0.1e: 429 files, 15M, built in 5.1 minutes
Run Code Online (Sandbox Code Playgroud)

然后我试过了

openssl version
Run Code Online (Sandbox Code Playgroud)

并且仍然(!)获得旧版本

moshe-mbp:~ moshem$ openssl version
OpenSSL 0.9.8r 8 Feb 2011
moshe-mbp:~ moshem$ 
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?我怎样才能安装cocoapods宝石?

谢谢


编辑,尝试@sean建议:

moshe-mbp:~ moshem$ brew update
Updated Homebrew from 672af665 to 10b4d426.
==> Updated Formulae
bash        wireshark
moshe-mbp:~ moshem$ brew install openssl
Error: openssl-1.0.1e already installed
moshe-mbp:~ moshem$ brew link openssl --force
Linking /usr/local/Cellar/openssl/1.0.1e... 1139 symlinks created
moshe-mbp:~ moshem$ brew install curl-ca-bundle
Error: curl-ca-bundle-1.87 already installed
moshe-mbp:~ moshem$ 
moshe-mbp:~ moshem$ openssl version
OpenSSL 0.9.8r 8 Feb 2011
moshe-mbp:~ moshem$ gem install cocoapods
ERROR:  Could not find a valid gem 'cocoapods' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server key exchange B: bad ecpoint (https://rubygems.org/latest_specs.4.8.gz)
Run Code Online (Sandbox Code Playgroud)

编辑(2)解决了布鲁医生的问题

moshe-mbp:~ moshem$ gem install cocoapods
ERROR:  Could not find a valid gem 'cocoapods' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server key exchange B: bad ecpoint (https://rubygems.org/latest_specs.4.8.gz)
moshe-mbp:~ moshem$ openssl version
OpenSSL 0.9.8r 8 Feb 2011
moshe-mbp:~ moshem$ brew update
Updated Homebrew from 10b4d426 to 6a00bc3c.
==> Updated Formulae
clozure-cl  python  python3
moshe-mbp:~ moshem$ brew install openssl
Error: openssl-1.0.1e already installed
moshe-mbp:~ moshem$ 
moshe-mbp:~ moshem$ echo $PATH
/Users/moshem/.rvm/gems/ruby-2.0.0-p0/bin:/Users/moshem/.rvm/gems/ruby-2.0.0-p0@global/bin:/Users/moshem/.rvm/rubies/ruby-2.0.0-p0/bin:/Users/moshem/.rvm/bin:/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/tools:/platforms:/platform-tools:
moshe-mbp:~ moshem$ 
Run Code Online (Sandbox Code Playgroud)

改变/ etc/paths后编辑

我将/ etc/path文件编辑为:

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
Run Code Online (Sandbox Code Playgroud)

完全关闭终端并重新打开,它仍然启动旧版本的openssl!

为什么?

moshe-mbp:~ moshem$ env $PATH
env: /Users/moshem/.rvm/gems/ruby-2.0.0-p0/bin:/Users/moshem/.rvm/gems/ruby-2.0.0-p0@global/bin:/Users/moshem/.rvm/rubies/ruby-2.0.0-p0/bin:/Users/moshem/.rvm/bin:/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/tools:/platforms:/platform-tools
Run Code Online (Sandbox Code Playgroud)

编辑,我的bash_profile

source "`brew --prefix grc`/etc/grc.bashrc"

export PATH=${JAVA_HOME}/bin:$PATH
export PATH="$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platforms:$ANDROID_SDK/platform-tools:$ANDROID_NDK"

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Run Code Online (Sandbox Code Playgroud)

顺便说一下,我的机器上似乎不存在/etc/grc.bashrc.此行和末尾的rvm行都是通过已安装的脚本添加的


编辑

moshe-mbp:~ moshem$ rvm pkg install openssl 
Fetching openssl-1.0.1c.tar.gz to /Users/moshem/.rvm/archives
Extracting openssl to /Users/moshem/.rvm/src/openssl-1.0.1c
Configuring openssl in /Users/moshem/.rvm/src/openssl-1.0.1c.
Compiling openssl in /Users/moshem/.rvm/src/openssl-1.0.1c.
Installing openssl to /Users/moshem/.rvm/usr

Please note that it's required to reinstall all rubies:

    rvm reinstall all --force

Updating openssl certificates
moshe-mbp:~ moshem$ openssl version
OpenSSL 1.0.1e 11 Feb 2013


moshe-mbp:~ moshem$ gem source -r http://rubygems.org/
http://rubygems.org/ removed from sources
moshe-mbp:~ moshem$ gem source -a https://rubygems.org/
Error fetching https://rubygems.org/:
    SSL_connect returned=1 errno=0 state=SSLv3 read server key exchange B: bad ecpoint (https://rubygems.org/specs.4.8.gz)
moshe-mbp:~ moshem$ gem install cocoapods
ERROR:  Could not find a valid gem 'cocoapods' (>= 0) in any repository
Run Code Online (Sandbox Code Playgroud)

小智 78

这是通过避免https和使用不安全的http来修复的.运行这个对我有用.

gem source -a http://rubygems.org/
Run Code Online (Sandbox Code Playgroud)

  • 因为答案表明这是"不安全" (14认同)
  • 对于其他看到此内容的人:也删除旧的来源.宝石源-r https://rubygems.org/ (3认同)

ant*_*paw 55

rvm osx-ssl-certs update all
Run Code Online (Sandbox Code Playgroud)

为我做了诀窍,ruby 2.0.0

  • 出于某种原因,我的权限在/ etc/openssl上是不正确的.修复:sudo chmod og + rw/etc/openssl.(如果你有权限问题,请运行以上命令进行实际修复).此评论适用于其他人,而不是此答案的作者. (3认同)

Ern*_*ons 37

尝试使用http://rubygems.org/(不使用SSL)作为源 - 为我修复了错误.

gem source -r https://rubygems.org/
gem source -a http://rubygems.org/
gem install cocoapods
Run Code Online (Sandbox Code Playgroud)

  • 这是有效的...谢谢!但我觉得我在作弊,因为我仍然有一个破损的openSSL安装,它可能会破坏我机器上的其他东西.. (2认同)
  • 这个答案略好于接受的答案,因为它包括删除安全源的步骤.当我尝试使用接受的答案时,只需添加不安全的源,安装命令仍然会因原始错误而失败,因为安全源仍在源列表中并且首先使用它. (2认同)

mpa*_*pis 25

当前发布的rvm可以更好地处理这些事情,运行:

rvm get head
rvm reload
rvm autolibs enable
rvm reinstall 1.9.3 --disable-binary
Run Code Online (Sandbox Code Playgroud)

请务必遵循任何显示的说明 - 这一切都可以帮助您.


Sea*_*ean 11

我有同样的错误.要解决只是运行以下命令(我知道你已经运行了一些,但幽默我):

brew update
brew install openssl
brew link openssl --force
brew install curl-ca-bundle
Run Code Online (Sandbox Code Playgroud)

之后,打开一个新的shell或源文件,所有应该是好的去:)

更新:

要更新路径,您需要编辑/ etc/paths文件,以便执行以下操作:

sudo vim /etc/paths
Run Code Online (Sandbox Code Playgroud)

应该看起来像:

/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
Run Code Online (Sandbox Code Playgroud)

您要做的是确保它/usr/local/bin位于文件的顶部.所以将它改为:

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
Run Code Online (Sandbox Code Playgroud)

希望能解决它!


gij*_*ijs 10

这就是为我解决的问题:安装此证书:https://raw.githubusercontent.com/rubygems/rubygems/master/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem

在此文件夹中:{rubyfolder}\lib\ruby​​\2.1.0\ruby​​gems\ssl_certs

这样您就不必添加不安全的来源.

更多信息:https://gist.github.com/luislavena/f064211759ee0f806c88


Elo*_*han 5

如果您在中国,请尝试使用http://ruby.taobao.org/ 作为来源 - 为我修复错误.同时,避免使用https.运行这个对我有用.

gem sources --remove https://rubygems.org/
gem sources -a http://ruby.taobao.org/
gem install cocoapods
Run Code Online (Sandbox Code Playgroud)