【问题标题】:gem eventmachine fatal error: 'openssl/ssl.h' file not foundgem eventmachine 致命错误:找不到“openssl/ssl.h”文件
【发布时间】:2015-08-29 08:50:02
【问题描述】:

刚安装 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

【问题讨论】:

    标签: ruby macos openssl homebrew eventmachine


    【解决方案1】:
    $ 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.
    • 如果您将 gems 设置到 repo 中的特定目录,即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'。这对我有用。不是这个。
    • 这对我有用 gem install eventmachine -v 1.0.8 -- --with-cppflags=-I/usr/local/opt/openssl/include 在 OSX El Capitan 10.11.5
    • 安装后对我来说brew install openssl我必须做brew link openssl --force
    【解决方案2】:

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

    $ 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
    【解决方案3】:
    brew link --force openssl
    

    然后:

    gem install eventmachine
    

    它还修复了:

    • gem 安装任务
    • 捆绑安装
    • rake 和 rails 任务

    附:可能您需要删除并再次运行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)。
    • 也为我工作。好电话。
    【解决方案4】:
    gem pristine eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include
    

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

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

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

    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 为我工作。
    【解决方案5】:

    我试图安装 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
    【解决方案6】:

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

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

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

    gem install mailcatcher
    

    【讨论】:

      【解决方案7】:

      这解决了我的问题:

      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,或者你使用什么
      【解决方案8】:

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

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

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

      【讨论】:

      • 可爱,仍然可以在 M1 MBP 和 Ruby 3.x 上工作。
      【解决方案9】:

      这对我有用 -

          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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-10-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-12-18
        • 2020-10-02
        • 2015-01-20
        • 2014-12-21
        相关资源
        最近更新 更多