Ruby gem安装失败,因为找不到Homebrew安装的openssl

cld4siwp  于 2023-06-29  发布在  Ruby
关注(0)|答案(1)|浏览(284)

当我尝试安装一个依赖于openssl的Ruby gem时,我得到了(在其他日志行中):

fatal error: 'openssl/sha.h' file not found
#include <openssl/sha.h>

如果我通过Homebrew在/opt/homebrew/Cellar/openssl@1.1/opt/homebrew/Cellar/openssl@3安装了openssl,那么正确的安装方法是什么?

gk7wooem

gk7wooem1#

它是这样工作的:

$ gem install eventmachine -- --with-openssl-dir=/opt/homebrew/Cellar/openssl\@1.1/1.1.1u/

目录/opt/homebrew/Cellar/openssl@1.1/1.1.1u/是Homebrew安装OpenSSL 1.1的地方。也适用于/opt/homebrew/Cellar/openssl@3/3.1.0/
一个规范的方法,据我所知,如下所示:

$ rvm pkg install openssl
$ rvm reinstall ruby-3.2.1 --with-openssl-dir=$HOME/.rvm/usr
$ gem install eventmachine

如果希望Ruby使用Homebrew安装的openssl:

$ brew install openssl@1.1
$ rvm reinstall ruby-3.2.1 --with-openssl-dir=/opt/homebrew/Cellar/openssl\@1.1/1.1.1u
$ gem install eventmachine

我不得不把这个放进~/.profile(在运行rvm reinstall之前!):

export CPPFLAGS="${CPPFLAGS} -I/opt/homebrew/Cellar/openssl@1.1/1.1.1u/include"

相关问题