ruby gem 安装失败,openssl 失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15305350/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 05:48:57  来源:igfitidea点击:

gem install fails with openssl failure

rubymacosrubygemsopensslcocoapods

提问by Moshe Marciano

I tried to install cocoapods (http://cocoapods.org/) on my OSX Mountain Lion.

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

first I tried

首先我试过

 rvm reinstall all --force

then I tried

然后我试过了

 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

I then tried

然后我尝试

openssl version

and still(!) gets the older version

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

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

what am I doing wrong? how can I install the cocoapods gem?

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

thanks

谢谢



EDIT, trying @sean suggestion:

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


EDIT (2) after fixing issues with brew doctor

修复 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$ 


EDIT after altering the /etc/paths

更改 /etc/paths 后编辑

I edited the /etc/path files to:

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

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

closed terminal completly and reopend and it still launches the old version of openssl!

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

why?

为什么?

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


EDIT, my bash_profile

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

BTW, the /etc/grc.bashrc doesn't seem to exist on my machine. both this line and the rvm line at the end were added by installed scripts

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



EDIT

编辑

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

回答by Ackshaey Singh

This is fixed by avoiding https and using the insecure http instead. Running this worked for me.

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

gem source -a http://rubygems.org/

回答by antpaw

rvm osx-ssl-certs update all

did the trick for me, ruby 2.0.0

对我有用,ruby 2.0.0

回答by Ernests Karlsons

Try using http://rubygems.org/(without SSL) as a source — that fixed the error for me.

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

gem source -r https://rubygems.org/
gem source -a http://rubygems.org/
gem install cocoapods

回答by mpapis

Current release of rvm does a lot better job handling this things, run:

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

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

Make sure to follow any displayed instructions - it's all there to help you.

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

回答by Sean

I had the same error. To fix just run the following commands (I know you've ran some but humor me):

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

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

After that, open a new shell or source your files and all should be good to go :)

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

UPDATE:

更新:

To update your paths you'll need to edit your /etc/paths file so do something like:

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

sudo vim /etc/paths

In there is should look something like:

在那里应该看起来像:

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

What you want to do is to ensure that /usr/local/binis at the top of the file. So change it to something like:

您要做的是确保它/usr/local/bin位于文件的顶部。所以把它改成这样:

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

Hope that fixes it!

希望修复它!

回答by gijswijs

This is what solved it for me: Install this certificate: 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/AddTrustExternalCARoot-2048.pem

In this folder: {rubyfolder}\lib\ruby\2.1.0\rubygems\ssl_certs

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

This way you don't have to add insecure sources.

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

More info here: https://gist.github.com/luislavena/f064211759ee0f806c88

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

回答by ElonChan

If you are in China, try using http://ruby.taobao.org/as a source — that fixed the error for me. At the same time,avoid https. Running this worked for me.

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

gem sources --remove https://rubygems.org/
gem sources -a http://ruby.taobao.org/
gem install cocoapods

回答by Scotty

The following got everything working for me!

以下让一切对我有用!

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

If this doesn't work, remove your existing rubygems and follow this:

如果这不起作用,请删除现有的 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

回答by Jan Hegewald

You can first install a newer openssl, as Mike Slutsky described. To check your openssl version:

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

$ openssl version

Get a more recent one here: http://www.openssl.org/source/Then configure and install it:

在此处获取更新的一个: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

Now configure ruby with this openssl:

现在用这个 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

Note: the new openssl does not need to be on you $PATH. This worked for me with ruby 2.0 and 2.1. Good luck (-:

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

回答by Mike S

You can try to update OpenSSL from source instead:

您可以尝试从源代码更新 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

source

来源