【发布时间】:2020-04-23 14:53:17
【问题描述】:
我遇到了在新 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。 (塞拉)
- 自制 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 开发)、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
后续步骤
目前我陷入困境 - 无法通过此步骤或通过查看其他帖子进行验证以获得有效的解决方案。
【问题讨论】:
-
你能显示你正在使用/用于安装 ruby-2.3.3 和 rails 的命令吗?只是预感,但我不建议通过 rvm 安装 rails。通过rvm安装ruby比较可靠,然后通过
gem install rails --no-ri --no-rdoc安装rails -
尝试检查 rvm 正在使用的证书的状态:
rvm osx-ssl-certs status all。这将输出每个证书的状态。如果不是Up to date,可以用rvm osx-ssl-certs update all更新。 -
同意使用 gem 安装导轨 - 这是我通常做的 - 描述中可能不清楚。
-
检查了 rvm 正在使用的证书,运行该命令没有输出。
标签: ruby-on-rails macos openssl rvm homebrew