Gem报错:找不到文件‘OpenSSL/ssl.h?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (8)
  • 关注 (0)
  • 查看 (93)

刚刚安装了El Capitan,可是无法安装GEMeventmachine1.0.7。openssl的版本号为:1.0.2a-1。我试着用--with-ssl-dir但被忽视了。

提交到GitHub仓库也是一样。

$ 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
提问于
用户回答回答于
$ 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

也可以这样设置bundler

bundle config build.eventmachine --with-cppflags=-I/usr/local/opt/openssl/include
用户回答回答于

我是这样解决问题的

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

用户回答回答于

另一种方法是为用户的配置文件添加一个bundler配置,如下所示:

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

当运行bundle install时, 它将在你的主目录中创建一个.bundle/config文件。

用户回答回答于

我用下面的命令成功安装了gem v1.0.3

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

用户回答回答于

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

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

然后你可以使用下面的命令安装Gem

gem install mailcatcher
用户回答回答于
gem pristine eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include

删除旧版本的Gem并重新编译它。

CPP选项标志允许编译器找到OpenSSL的头文件。

还可以添加版本:

gem pristine eventmachine -v '1.0.4' -- --with-cppflags=-I/usr/local/opt/openssl/include
用户回答回答于
brew link --force openssl

然后:

gem install eventmachine

它修复了:

  • gem install 任务
  • bundle安装
  • RAKE和Rails任务

注。你需要移除并运行brew install openssl

苹果已经从OSX中删除了OpenSSL。

用户回答回答于

当使用bundler和homebrew的时候:

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

扫码关注云+社区