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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30818391/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 06:44:48  来源:igfitidea点击:

gem eventmachine fatal error: 'openssl/ssl.h' file not found

rubymacosopensslhomebreweventmachine

提问by firedev

Just installed El Capitan and can't install gem eventmachine1.0.7. opensslis at 1.0.2a-1. Tried to use --with-ssl-dirbut it seems ignored.

刚刚安装了 El Capitan 并且无法安装 gem eventmachine1.0.7openssl1.0.2a-1。尝试使用,--with-ssl-dir但似乎被忽略了。

Reported it to their github repoas well.

也将其报告给了他们的github repo

Any suggestions are really appreciated. Thanks.

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

$ 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

回答by 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

You can also set up bundler like this but I think that is superficial

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

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

回答by Lloeki

When using bundler and homebrew:

使用 bundler 和 homebrew 时:

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

回答by itsnikolay

brew link --force openssl

Then:

然后:

gem install eventmachine

It also fixes:

它还修复了:

  • gem install taks
  • bundle install
  • rake and rails tasks
  • gem 安装任务
  • 捆绑安装
  • 耙子和导轨任务

P.S. Probably you'll need to remove and run brew install opensslagain

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

The issue happends because Apple had removed openssl from OSX (in El Captain build)

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

回答by jLuc

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

pristine removes the old gem and recompiles it.

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

The cpp flags option allows the compiler to find the openssl headers.

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

You can also add the version if you like:

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

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

回答by Ana Isabel

I was trying to install v 1.0.3 and this worked for me.

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

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

These discussions were very helpful. https://github.com/eventmachine/eventmachine/issues/602

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

回答by Andrew

If you're installing EventMachine as a dependency of another gem, be sure to specify the correct version when you manually install the gem:

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

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

Then you can install the gem that you were originally trying to install:

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

gem install mailcatcher

回答by Fredrik Br?nstr?m

One alternative is to add a bundler config entry for your whole user profile, like this:

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

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

it'll create a .bundle/config file in your home directory, which is then used in all your projects when you run bundle install.

它将在您的主目录中创建一个 .bundle/config 文件,然后在您运行bundle install.

回答by Giovanni Benussi

This solved the problem for me:

这为我解决了问题:

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

Source: https://github.com/sj26/mailcatcher/issues/254

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

回答by ARK

This worked for me -

这对我有用-

    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

NOTE:-Before I was able to successfully install this gem, I had to do a few things. These might apply to you, so listing them here -

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

1.) got off the corporate-VPN OR you might have to turn ON proxy settings

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

2.) PKG_CONFIG_PATH was set to -

2.) PKG_CONFIG_PATH 被设置为 -

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

3.) had to add the following to $PATH in bash_profile (in my case ~/.zshrc)

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

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

4.) Also note, that contrary to some answers I got in this SO post, and also this thread on github-eventmachine, I was not able to install eventmachine

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.

It seems /usr/local/opt/openssl/includeis the right location and not /usr/local/includewhen specifying the openssl location.

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