简体   繁体   English

使用rbenv在Mac上安装ruby 2.0.0-p195时出现OpenSSL错误

[英]OpenSSL error installing ruby 2.0.0-p195 on Mac with rbenv

I'm trying to install Ruby 2.0.0-p195 using rbenv on a Mac (Mountain Lion) and got this error. 我正在尝试在Mac(Mountain Lion)上使用rbenv安装Ruby 2.0.0-p195并出现此错误。

BUILD FAILED

Inspect or clean up the working tree at /var/folders/vt/27n8h2yj27v7rzq58075f3_m0000gn/T/ruby-build.20130618163859.1669
Results logged to /var/folders/vt/27n8h2yj27v7rzq58075f3_m0000gn/T/ruby-build.20130618163859.1669.log

Last 10 log lines:
installing default gems:      /Users/me/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0 (build_info, cache, doc, gems, specifications)
                              bigdecimal 1.2.0
                              io-console 0.4.2
                              json 1.7.7
                              minitest 4.3.2
                              psych 2.0.0
                              rake 0.9.6
                              rdoc 4.0.0
                              test-unit 2.0.0.0
The Ruby openssl extension was not compiled. Missing the OpenSSL lib?

When I ran brew install openssl it said 当我运行brew install openssl时,它说

Warning: openssl-1.0.1e already installed

Following a solution on this thread https://github.com/sstephenson/ruby-build/issues/305 I tried to install latest stable this way and got the same error 关于这个线程的解决方案https://github.com/sstephenson/ruby-build/issues/305我尝试以这种方式安装最新的稳定版并得到相同的错误

env CFLAGS='-g -O2' RUBY_CONFIGURE_OPTS="--with-readline-dir=`brew --prefix readline`" rbenv install 2.0.0-p195

Any ideas? 有任何想法吗?

Try adding OpenSSL to the config options using the --with-openssl-dir option: 尝试使用--with-openssl-dir选项将OpenSSL添加到配置选项:

$ CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl`" rbenv install 2.0.0-p195

If you're using Homebrew, you'll need to install OpenSSL before running the above by running: 如果您使用的是Homebrew,则需要在运行上述内容之前安装OpenSSL:

$ brew install openssl

UPDATE (see @JarkkoLaine 's comment below) : 更新 (见@JarkkoLaine的评论如下)

Just for the record, you should not need to use the config opts anymore with ruby-build and homebrew. 只是为了记录,你不应该再使用ruby-build和homebrew配置opts了。 However, I had to reinstall openssl with homebrew to make it work: brew uninstall openssl; 但是,我不得不用自制软件重新安装openssl以使其正常工作:brew uninstall openssl; brew upgrade; 酿造升级; brew install openssl; brew install openssl; rbenv install 2.0.0-p247. rbenv安装2.0.0-p247。 See this for more info. 有关详细信息,请参阅

I fixed this by executing: 我通过执行:

brew link openssl --force

Mac OSX 10.9.4 Mac OSX 10.9.4

Upgrading to the latest version of ruby-build fixed the problem for me: 升级到最新版本的ruby-build为我解决了这个问题:

Like the OP, I got 像OP一样,我得到了

BUILD FAILED

Inspect or clean up the working tree at /Users/me/.rbenv/sources/2.0.0-p247
Results logged to /var/folders/3x/y_8y8vr53ws_kxj97km79q5h0000gn/T/ruby-build.20130704172404.3106.log

Last 10 log lines:
installing default gems:      /Users/me/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0 (build_info, cache, doc, gems, specifications)
                              bigdecimal 1.2.0
                              io-console 0.4.2
                              json 1.7.7
                              minitest 4.3.2
                              psych 2.0.0
                              rake 0.9.6
                              rdoc 4.0.0
                              test-unit 2.0.0.0
The Ruby openssl extension was not compiled. Missing the OpenSSL lib?

but installing the latest version of ruby-build, via 但安装最新版本的ruby-build,via

# Don't forget brew doctor and brew update if required
brew upgrade ruby-build

fixed it. 固定它。

Ruby-build had some changes between when the OP asked and now, which would explain why it worked for me, but not for the OP using the latest stable version of ruby-build. Ruby-build在OP问及现在之间有一些变化,这可以解释为什么它适用于我,但不能解释使用最新稳定版本的ruby-build的OP。

For those who have problems installing openssl. 对于那些在安装openssl时遇到问题的人。

I had this error on my Mac 10.8.4 我的Mac 10.8.4上有这个错误

brew install openssl

created directory `/usr/local/Cellar/openssl/1.0.1e/include/openssl'
make: *** [install_sw] Error 13

READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting

These open issues may also help:
    https://github.com/mxcl/homebrew/pull/19429
  1. Create a directory if it does not exist 如果目录不存在,请创建一个目录

     sudo mkdir /usr/local/etc/openssl 
  2. Change the rights. 改变权利。 Replace and with your name and group (eg serge:admin) 替换并与您的姓名和组(例如哔叽:管理员)

     sudo chown -R <username>:<group> /usr/local/etc/openssl/ 
  3. Repeat openssl installation 重复openssl安装

     brew install openssl 
  4. Install curl-ca-bundle 安装curl-ca-bundle

     brew install curl-ca-bundle 
  5. install ruby 安装红宝石

     CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl`" rbenv install 2.0.0-p195 

Bingo 答对了

Solution using ruby-install: 使用ruby-install的解决方案:

After uninstalling and installing openssl a couple of times (probably unnecessary) I successfully tried this: 卸载并安装openssl几次(可能是不必要的)后我成功尝试了这个:

ruby-install ruby 2.1.3 -- --with-openssl-dir=`brew --prefix openssl`

缺少的库是libssl * -dev * / openssl * -dev *,具体取决于您的发行版。

This issue came up again for me with Mac OS 10.9.5 Mac OS 10.9.5再次出现了这个问题

Mac upgraded the command-line tools and that upgraded openssl, which broken rbenv. Mac升级了命令行工具并升级了openssl,这破坏了rbenv。

I tried all of these solutions, but none of them worked. 我尝试了所有这些解决方案,但都没有奏效。 Everything was up-to-date, but I couldn't install any new gems or build rubies. 一切都是最新的,但我无法安装任何新的宝石或建立红宝石。

My solution was to: 我的解决方案是:

  1. Remove the ruby version (for me it was 2.1.1) 删除ruby版本(对我来说它是2.1.1)
  2. Brew uninstall ruby-build and rbenv Brew卸载ruby-build和rbenv
  3. Brew Re-install rbenv and ruby-build Brew重新安装rbenv和ruby-build

Hope this helps you if you encounter it too! 希望如果您遇到它也可以帮助您!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM