英文:
Ruby gem install fails because it can't find openssl installed by Homebrew
问题
尝试安装依赖openssl的Ruby gem时,出现以下错误之一:
```text
fatal error: 'openssl/sha.h' 文件未找到
#include <openssl/sha.h>
如果我已经通过Homebrew安装了openssl,路径分别为 /opt/homebrew/Cellar/openssl@1.1
和 /opt/homebrew/Cellar/openssl@3
,应该如何正确安装它呢?
<details>
<summary>英文:</summary>
When I try to install a Ruby gem that depends on openssl, I'm getting (among other log lines):
```text
fatal error: 'openssl/sha.h' file not found
#include <openssl/sha.h>
What is the right way to install it, if I have openssl installed via Homebrew at /opt/homebrew/Cellar/openssl@1.1
and at /opt/homebrew/Cellar/openssl@3
.
答案1
得分: 1
这是它的工作方式:
$ 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"
英文:
This is how it worked:
$ gem install eventmachine -- --with-openssl-dir=/opt/homebrew/Cellar/openssl\@1.1/1.1.1u/
The directory /opt/homebrew/Cellar/openssl@1.1/1.1.1u/
is where Homebrew installed OpenSSL 1.1. Also works with /opt/homebrew/Cellar/openssl@3/3.1.0/
.
A canonical method, as I understand, is the following:
$ rvm pkg install openssl
$ rvm reinstall ruby-3.2.1 --with-openssl-dir=$HOME/.rvm/usr
$ gem install eventmachine
If it's desired to make Ruby use openssl installed by Homebrew:
$ 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
I had to put this into ~/.profile
(before running rvm reinstall
!):
export CPPFLAGS="${CPPFLAGS} -I/opt/homebrew/Cellar/openssl@1.1/1.1.1u/include"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论