在Mac上安装Nokogiri在使用Ruby 2.4构建的openssl上失败
我刚刚更新并重新加载了rvm,rvm安装了2.4.0,当我运行在Mac上安装Nokogiri在使用Ruby 2.4构建的openssl上失败,ruby,openssl,rubygems,nokogiri,Ruby,Openssl,Rubygems,Nokogiri,我刚刚更新并重新加载了rvm,rvm安装了2.4.0,当我运行gem时,我得到: ➜ ~ gem install irbtools ERROR: While executing gem ... (Gem::Exception) Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources ➜ 我在谷歌上搜索了一下,找到了几个据称有效的解决方案,但
gem
时,我得到:
➜ ~ gem install irbtools
ERROR: While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
➜
我在谷歌上搜索了一下,找到了几个据称有效的解决方案,但除了建议使用不安全的gem URL之外,没有找到一个有效的解决方案,我不想这样做
顺便说一句,openssl已安装,但不是由brew安装的:
➜ ruby-2.4.0 brew install openssl
Warning: openssl is a keg-only and another version is linked to opt.
Use `brew install --force` if you want to install this version
如何让gem使用安全的gem源代码?解决方案是安装brew的OpenSSL:
brew安装--强制openssl
(我收到一条奇怪的消息说,`--force被忽略了,但它确实安装正常。)
然后,执行brew信息openssl
和RTFM!:)根据它告诉我的,我在~/.zshrc文件中添加了以下内容:
Ruby 2.4要找到brew的OpenSSL:
导出LDFLAGS=-L/usr/local/opt/openssl/lib
导出CPPFLAGS=-I/usr/local/opt/openssl/include
导出PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig
然后,我打开了一个新的终端窗口,重新安装了Ruby 2.4:
rvm重新安装2.4
在那之后,gem
起作用。另请参见、、等。