ChatGPT解决这个技术问题 Extra ChatGPT

gem eventmachine 致命错误:找不到“openssl/ssl.h”文件

刚安装 El Capitan,无法安装 gem eventmachine 1.0.7openssl 位于 1.0.2a-1。尝试使用 --with-ssl-dir 但它似乎被忽略了。

也向他们的 github repo 报告。

任何建议都非常感谢。谢谢。

$ ls /usr/local/Cellar/openssl/1.0.2a-1/include/openssl/ssl.h
/usr/local/Cellar/openssl/1.0.2a-1/include/openssl/ssl.h

$ gem install eventmachine -v '1.0.7' -- --with-ssl-dir=/usr/local/Cellar/openssl/1.0.2a-1/include
/Users/pain/.rbenv/versions/2.1.2/bin/ruby -r ./siteconf20150612-56154-1hsjz2n.rb extconf.rb --with-ssl-dir=/usr/local/Cellar/openssl/1.0.2a-1/include
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... yes
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for inotify_init() in sys/inotify.h... no
checking for __NR_inotify_init in sys/syscall.h... no
checking for writev() in sys/uio.h... yes
checking for rb_thread_fd_select()... yes
checking for rb_fdset_t in ruby/intern.h... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_enable_interrupt()... no
checking for rb_time_new()... yes
checking for sys/event.h... yes
checking for sys/queue... yes
checking for clock_gettime()... no
checking for gethrtime()... no
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling binder.cpp
In file included from binder.cpp:20:
./project.h:116:10: fatal error: 'openssl/ssl.h' file not found
#include <openssl/ssl.h>
         ^
1 error generated.
make: *** [binder.o] Error 1

make failed, exit code 2

f
firedev
$ gem install eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include                                                                                                             
Building native extensions with: '--with-cppflags=-I/usr/local/opt/openssl/include'
This could take a while...
Successfully installed eventmachine-1.0.8
1 gem installed

您也可以像这样设置捆绑程序,但我认为这是肤浅的

bundle config build.eventmachine --with-cppflags=-I/usr/local/opt/openssl/include

对我来说,我必须先安装 openssl 才能工作。例如brew install openssl
如果您将 gem 设置到存储库中的特定目录,即 vendor/bundle,那么您将需要运行 bundle config build.GEMNAME--with-cppflags=-I/usr/local/opt/openssl/include。我必须用 gem puma 运行相同的东西,所以我想这也发生在其他 gem 上。
查看来自 lloeki 的答案:'bundle config build.eventmachine --with-cppflags=-I$(brew --prefix openssl)/include'。这对我有用。不是这个。
这在 OSX El Capitan 10.11.5 上对我有用 gem install eventmachine -v 1.0.8 -- --with-cppflags=-I/usr/local/opt/openssl/include
安装后对我来说brew install openssl我必须做brew link openssl --force
L
Lloeki

使用捆绑器和自制软件时:

$ bundle config build.eventmachine --with-cppflags=-I$(brew --prefix openssl)/include
$ bundle install

对我来说,我必须先安装 openssl 才能工作。例如brew install openssl
这个版本对我有用,可以在 ruby 2.1.2 之上安装 eventmachine 1.0.3
极好的!这也是依赖于 openssl 的其他 gem(例如 puma)的方法
我认为这个答案比批准的答案更好,因为它使用 bundle install 来执行实际的 gem 安装,它保证您将安装包中指定的确切版本。接受的答案将安装最新版本,除非您在 gem install 命令中手动包含 -v x.x.x
i
itsnikolay
brew link --force openssl

然后:

gem install eventmachine

它还修复了:

gem 安装任务

捆绑安装

rake 和 rails 任务

PS 可能您需要删除并再次运行 brew install openssl

问题发生是因为 Apple 已从 OSX 中删除了 openssl(在 El Captain 构建中)


这确实是对 El Capitan 的修复。
为了澄清, brew remove/install/link 的顺序是什么
@Abram 如果 brew link --force openssl 没有效果。然后执行 brew uninstall opensslbrew install opensslbrew link --force openssl
这就是今天在 Mac 上的答案(El Capitan,2015-2016)。编辑:只是强制 brew openssl。我不需要指定 EventMachine 的版本(我正在安装 Middleman)。
也为我工作。好决定。
m
m_floer
gem pristine eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include

pristine 删除旧的 gem 并重新编译它。

cpp 标志选项允许编译器找到 openssl 头文件。

如果您更喜欢抽象出 cpp flags 参数,您可以执行以下操作:

PKG_CONFIG_PATH="$(brew --prefix openssl)/lib/pkgconfig"

如果您愿意,还可以添加版本:

gem pristine eventmachine -v '1.0.4' -- --with-cppflags=-I/usr/local/opt/openssl/include

为什么是 pristine 而不是 install
gem install eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include 为我工作。
m
m_floer

我试图安装 v 1.0.3,这对我有用。

gem install eventmachine -v '1.0.3' -- --with-cppflags=-I/usr/local/opt/openssl/include

这些讨论非常有帮助:https://github.com/eventmachine/eventmachine/issues/602

这假设机器已经通过 brew 安装了 openssl。


I/usr/local/opt/openssl/include 之前需要一个连字符。这是一个字符,所以stackoverflow不允许我编辑它
修复它@MaicolBen
A
Andrew

如果您将 EventMachine 作为另一个 gem 的依赖项安装,请确保在手动安装 gem 时指定正确的版本:

gem install eventmachine -v 1.0.5 -- --with-cppflags=-I$(brew --prefix openssl)/include

然后您可以安装您最初尝试安装的 gem:

gem install mailcatcher

G
Giovanni Benussi

这为我解决了这个问题:

PKG_CONFIG_PATH="$(brew --prefix openssl)/lib/pkgconfig" gem install eventmachine -v "1.0.8"

来源:https://github.com/sj26/mailcatcher/issues/254


不必要的复杂,为什么不直接设置 var: export PKG_CONFIG_PATH=$( brew --prefix openssl )/lib/pkgconfig # 现在你可以安装任何包,添加到 .bashrc 或者你使用的包
F
Fredrik Bränström

一种替代方法是为您的整个用户配置文件添加一个捆绑器配置条目,如下所示:

cd ~
bundle config build.eventmachine --with-cppflags=-I$(brew --prefix openssl)/include

它将在您的主目录中创建一个 .bundle/config 文件,然后在您运行 bundle install 时在您的所有项目中使用该文件。


可爱,仍然适用于 M1 MBP 和 Ruby 3.x。
A
ARK

这对我有用 -

    gem install eventmachine -v '1.0.7' -- --debug --backtrace --with-cppflags=-I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib
    Building native extensions with: '--debug --backtrace --with-cppflags=-I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib'
    This could take a while...
    Successfully installed eventmachine-1.0.7
    Parsing documentation for eventmachine-1.0.7
    Installing ri documentation for eventmachine-1.0.7
    Done installing documentation for eventmachine after 9 seconds
    1 gem installed

注意:- 在我能够成功安装这个 gem 之前,我必须做一些事情。这些可能适用于您,因此在此处列出它们 -

1.) 关闭企业 VPN 或者您可能必须打开代理设置

2.) PKG_CONFIG_PATH 设置为 -

echo $PKG_CONFIG_PATH
/usr/local/opt/openssl/lib/pkgconfig

3.) 必须将以下内容添加到 bash_profile 中的 $PATH(在我的情况下为 ~/.zshrc)

export PATH="/usr/local/opt/openssl/bin:$PATH"

4.) 另请注意,与我在此 SO 帖子中得到的一些答案以及 github-eventmachine 上的此线程相反,我无法安装 eventmachine

gem install eventmachine -v '1.0.7' -- --debug --backtrace --with-cppflags=-I/usr/local/include --with-ldflags=-L/usr/local/lib
Fetching: eventmachine-1.0.7.gem (100%)
Building native extensions with: '--debug --backtrace --with-cppflags=-I/usr/local/include --with-ldflags=-L/usr/local/lib'
This could take a while...
ERROR:  Error installing eventmachine:
    ERROR: Failed to build gem native extension.

在指定 openssl 位置时,似乎 /usr/local/opt/openssl/include 是正确的位置,而不是 /usr/local/include


H
Heath Borders

这看起来像是一个更新的问题:https://github.com/eventmachine/eventmachine/issues/936

我在 macOS 12.3.1 上解决了这个问题,方法如下:

M1 最大值:

gem install eventmachine -- --with-openssl-dir=/opt/homebrew/Cellar/openssl@1.1/1.1.1n/

英特尔:

gem install eventmachine -- --with-openssl-dir=/usr/local/Cellar/openssl@1.1/1.1.1n/

D
Dorian

对于杰基尔和鱼:

gem install jekyll -- --with-cppflags=-I(brew --prefix openssl)/include

J
John Skiles Skinner

这为我安装了它:

gem install eventmachine -- --with-openssl-dir=/usr/local/opt/openssl@1.1

我从 the eventmachine Github repo 得到的。显然,OpenSSL 工具在某个时候从 MacOS 中移动/删除。

就我而言,我想安装依赖于 eventmachine 的其他东西(mailcatcher)。我通过在上述命令中将 eventmachine 替换为 mailcatcher 来做到这一点。