63

我试图在我的 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)

首先我试过

 rvm reinstall all --force

然后我尝试了

 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

然后我尝试了

openssl version

仍然(!)获取旧版本

moshe-mbp:~ moshem$ openssl version
OpenSSL 0.9.8r 8 Feb 2011
moshe-mbp:~ moshem$ 

我究竟做错了什么?如何安装 cocoapods gem?

谢谢


编辑,尝试@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)

修复 brew doctor 的问题后编辑(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$ 

修改 /etc/paths 后编辑

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

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

完全关闭终端并重新打开它仍然启动旧版本的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

编辑,我的 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*

顺便说一句,我的机器上似乎不存在 /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
4

11 回答 11

78

这可以通过避免使用 https 并改用不安全的 http 来解决。运行这个对我有用。

gem source -a http://rubygems.org/
于 2013-10-01T14:23:13.290 回答
55
rvm osx-ssl-certs update all

对我有用,红宝石2.0.0

于 2013-10-05T11:17:40.653 回答
38

尝试使用http://rubygems.org/(没有 SSL)作为源——这为我修复了错误。

gem source -r https://rubygems.org/
gem source -a http://rubygems.org/
gem install cocoapods
于 2013-03-10T17:46:30.093 回答
26

当前版本的 rvm 在处理这些事情上做得更好,运行:

rvm get head
rvm reload
rvm autolibs enable
rvm reinstall 1.9.3 --disable-binary

确保遵循任何显示的说明 - 一切都可以为您提供帮助。

于 2013-08-08T22:07:06.323 回答
11

我有同样的错误。要修复,只需运行以下命令(我知道你已经运行了一些但幽默我):

brew update
brew install openssl
brew link openssl --force
brew install curl-ca-bundle

之后,打开一个新的 shell 或获取你的文件,一切都应该很好:)

更新:

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

sudo vim /etc/paths

那里应该看起来像:

/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin

您要做的是确保它/usr/local/bin位于文件的顶部。因此,将其更改为:

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

希望修复它!

于 2013-03-09T01:44:15.740 回答
9

更新 2021-05-20:Rubygems 更改了他们使用的证书。我已经更新了证书的链接,但我还没有确认这个解决方案实际上仍然有效。

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

https://raw.githubusercontent.com/rubygems/rubygems/master/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem

在此文件夹中:{rubyfolder}\lib\ruby\xxx\rubygems\ssl_certs

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

更多信息在这里:https://gist.github.com/luislavena/f064211759ee0f806c88 https://www.develves.net/blogs/asd/2016-04-08-rubygems-and-ssl/

于 2014-12-17T20:49:56.840 回答
5

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

gem sources --remove https://rubygems.org/
gem sources -a http://ruby.taobao.org/
gem install cocoapods
于 2015-02-09T10:21:12.083 回答
4

以下让一切都为我工作!

rvm get stable

brew update

brew install libyaml
brew install pkg-config 
brew install libxml2 
brew install libxslt

brew install openssl
brew link openssl --force

brew install sqlite

brew install apple-gcc42

rvm install 2.0.0 --with-gcc=gcc-4.2

如果这不起作用,请删除您现有的 ruby​​gems 并按照以下步骤操作:

rvm remove 2.0.0
rvm get head --autolibs=3
rvm requirements

#At this point, brew install anything that's missing, like apple-gcc42.

rvm install 2.0.0 --with-gcc=gcc-4.2
于 2013-03-11T11:56:42.353 回答
2

正如 Mike Slutsky 所描述的,您可以先安装更新的 openssl。要检查您的 openssl 版本:

$ openssl version

在这里获取更新的:http ://www.openssl.org/source/ 然后配置并安装它:

$ cd openssl-1.0.1f_src/
$ ./Configure --prefix=/Users/me/bin/openssl-1.0.1f_bin darwin64-x86_64-cc
$ make install

现在用这个 openssl 配置 ruby​​:

$ cd ruby-2.1.0_src/
$ ./configure --with-openssl-dir=/Users/me/bin/openssl-1.0.1f_bin --prefix=/Users/me/bin/ruby-2.1.0_bin

注意:新的 openssl 不需要在你的 $PATH 上。这对我来说适用于 ruby​​ 2.0 和 2.1。祝你好运 (-:

于 2014-01-22T10:17:10.057 回答
1

您可以尝试从源代码更新 OpenSSL:

curl -L -O http://www.openssl.org/source/openssl-1.0.1b.tar.gz.asc
curl -L -O http://www.openssl.org/source/openssl-1.0.1b.tar.gz
gpg --verify openssl-1.0.1b.tar.gz.asc
tar xvzf openssl-1.0.1b.tar.gz
cd openssl-1.0.1b
perl ./Configure shared zlib --prefix=/opt/local darwin64-x86_64-cc
make
make test
sudo make install

来源

于 2013-03-09T14:27:51.080 回答
0

我通过仅附加到 ~/.bash_profile 中的 PATH 变量来修复它,在我的情况下,这意味着改变

export PATH="/usr/local/mysql/bin:$PATH"
export PATH=$M2:$PATH
export PATH=$JAVA_HOME/bin:$PATH

export PATH="$PATH:/usr/local/mysql/bin"
export PATH=$PATH:$M2
export PATH=$PATH:$JAVA_HOME/bin

在终端中,键入nano ~/.bash_profile以开始编辑。

于 2015-04-08T21:11:55.200 回答