在Mac OS X Sierra上安装RVM,Ruby:无法要求openssl

时间:2017-01-30 22:37:39

标签: ruby-on-rails macos openssl rvm homebrew

我在新的Mac笔记本电脑上遇到了设置RVM + Rubies的问题,在安装了RVM和Homebrew之后,Rails的安装就出现了错误:

ERROR:  While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

背景和环境

  • Mac OS X 10.12.3。 (Sierra)
  • Homebrew 1.1.8。安装了OpenSSL
  • RVM 1.28.0
  • Ruby 2.3.3 Rails(尝试安装最新版本)
  • 环境变量(在OpenSSL crate fails compilation on Mac OS X 10.11之后)已在Shell环境中设置以下变量
  • LDFLAGS = -L/usr/local/opt/openssl@1.1/lib
  • CPPFLAGS = -I/usr/local/opt/openssl@1.1/include
  • PKG_CONFIG_PATH = /usr/local/opt/openssl@1.1/lib/pkgconfig

发现&故障诊断

从一台干净的笔记本电脑开始,我遵循了安装Homebrew,Xcode命令行工具,MySQL(用于rails dev),Git和RVM的通常路径。即使设置了环境变量以及卸载和重建RVM,在Homebrew中删除并重新添加OpenSSL,在尝试安装Rails时我也会遇到错误:

ERROR:  While executing gem ... (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

要注意的另一个问题是,在安装RVM时,我确保RVM知道Homebrew:

rvm autolibs enable
ram autolibs homebrew

安装ruby-2.3.3的输出如下:

Searching for binary rubies, this might take some time.
Found remote file https://rubies.travis-ci.org/osx/10.12/x86_64/ruby-2.3.3.tar.bz2
Checking requirements for osx_brew.
Updating Homebrew...
Certificates in '/usr/local/etc/openssl/cert.pem' are already up to date.
Requirements installation successful.
ruby-2.3.3 - #configure
ruby-2.3.3 - #download
ruby-2.3.3 - #validate archive
ruby-2.3.3 - #extract
ruby-2.3.3 - #validate binary
Libraries missing for ruby-2.3.3: /Users/travis/.rvm/rubies/ruby-2.3.3/lib/libruby.2.3.0.dylib. Refer to your system manual for installing libraries
Mounting remote ruby failed with status 10, trying to compile.
Checking requirements for osx_brew.
Certificates in '/usr/local/etc/openssl/cert.pem' are already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/grantsayer/.rvm/rubies/ruby-2.3.3, this may take a while depending on your cpu(s)...
ruby-2.3.3 - #downloading ruby-2.3.3, this may take a while depending on your connection...
ruby-2.3.3 - #extracting ruby-2.3.3 to /Users/grantsayer/.rvm/src/ruby-2.3.3

后续步骤

目前我被困 - 无法通过此步骤或通过审核其他帖子进行验证,以获得有效的解决方案。

2 个答案:

答案 0 :(得分:15)

我找到了解决之前描述的问题的方法。以下步骤概述了解决方法。

<强>清理

  1. 通过ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

  2. 删除了Homebrew的安装
  3. 通过rvm implode

  4. 删除了RVM的安装

    <强>重建

    1. 使用ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

    2. 安装Homebrew
    3. 使用brew upgrade后跟brew doctor

    4. 对Brew进行完整性检查
    5. 使用\curl -sSL https://get.rvm.io | bash -s stable
    6. 安装RVM(再次!)
    7. 使用autolibs
    8. 确保RVM通过rvm autolibs homebrew选项了解自制软件
    9. 设置环境变量,以便我们知道openssl的安装位置:

      导出LDFLAGS = -L / usr / local / opt / openssl / lib

      导出CPPFLAGS = -I / usr / local / opt / openssl / include

      export PKG_CONFIG_PATH = / usr / local / opt / openssl / lib / pkgconfig

    10. 通过rvm install 2.3.3 --autolibs=homebrew

    11. 安装ruby

      检查它是否有效

      1. 使用rvm osx-ssl-certs status all检查rvm空间是否了解OpenSSL证书。运行此命令会产生以下输出:Certificates for /usr/local/etc/openssl/cert.pem: Up to date.

      2. 通过gem install rails

      3. 安装导轨

        在最后一步安装成功并且Rails正在工作(最后!)

答案 1 :(得分:0)

如果这对另一位读者不起作用 - 试试这个:

rvm get branch /bugfix/3923_set_osx_brew_openssl_compiler_config
rvm install 2.4.0

如果这对你有用,go to the rvm issue并告诉开发人员你多么欣赏他的努力:)