简体   繁体   English

无法在OS X Yosemite上构建puma gem

[英]Cannot build puma gem on OS X Yosemite

(Revised) question: (修订)问题:

What does it take install puma gem on my OS X Yosemite (10.10.1) system? 在OS X Yosemite(10.10.1)系统上安装puma gem有什么用? I've exhausted a bunch of avenues (I have XCode tools, I have OpenSSL), but it still fails while trying to build the native extensions. 我已经用尽了很多方法(我有XCode工具,我有OpenSSL),但是在尝试构建本机扩展时仍然失败。

The Problem 问题

On my OS X system, when I do: 在OS X系统上,当我这样做时:

$ gem install puma

I get: 我得到:

Building native extensions.  This could take a while...
ERROR:  Error installing puma:
        ERROR: Failed to build gem native extension.

    /Users/home/sandbox/usr/bin/ruby extconf.rb
checking for SSL_CTX_new() in -lssl... no
checking for SSL_CTX_new() in -lssleay32... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/Users/home/sandbox/usr/bin/ruby
        --with-puma_http11-dir
        --without-puma_http11-dir
        --with-puma_http11-include
        --without-puma_http11-include=${puma_http11-dir}/include
        --with-puma_http11-lib
        --without-puma_http11-lib=${puma_http11-dir}/lib
        --with-ssllib
        --without-ssllib
        --with-ssleay32lib
        --without-ssleay32lib

extconf failed, exit code 1

Gem files will remain installed in /Users/home/sandbox/usr/lib/ruby/gems/2.1.0/gems/puma-2.10.2 for inspection.
Results logged to /Users/home/sandbox/usr/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-14/2.1.0/puma-2.10.2/gem_make.out

The Environment 环境

I suspect that gem install is unable to locate the SSL headers and/or libraries. 我怀疑gem install无法找到SSL标头和/或库。 Here's what I've got on my system (note that ~/sandbox/usr is my "sandbox" directory, containing all executables, libraries, headers, etc for my Ruby on Rails development). 这是我在系统上得到的(请注意〜/ sandbox / usr是我的“ sandbox”目录,其中包含Ruby on Rails开发的所有可执行文件,库,标头等)。 Notice that "ssl.h" does define SSL_CTX_new(): 请注意,“ ssl.h”确实定义了SSL_CTX_new():

$ which openssl
~/sandbox/usr/bin/openssl
$ openssl version
OpenSSL 1.0.1j 15 Oct 2014
$ openssl version -d
OPENSSLDIR: "/Users/home/sandbox/usr/ssl"
$ find ~/sandbox/usr -name "*libssl*" -print
~/sandbox/usr/lib/libssl.a
$ find ~/sandbox/usr -name "*.h" -exec grep SSL_CTX_new {} /dev/null \;
~/sandbox/usr/include/openssl/ssl.h:SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth);

Also, here's how ruby was compiled. 另外,这是ruby的编译方式。 $INSTALL_DIR is ~/home/sandbox: $ INSTALL_DIR是〜/ home / sandbox:

./configure --prefix=$(INSTALL_DIR) --enable-shared --disable-install-doc --with-opt-dir=$(INSTALL_DIR) --with-openssl-dir=$(INSTALL_DIR)/bin; where INSTALL_DIR is ~/sandbox/usr. 

The Question 问题

Am I simply missing some configuration flags for the build process? 我是否只是在构建过程中缺少一些配置标志? I've tried a bunch of flags more or less at random: 我或多或少地随机尝试了一堆标志:

$ gem install puma -- --with-openssl-dir=/Users/home/sandbox/usr/ssl
$ gem install puma -- --with-ssllib=/Users/home/sandbox/usr/lib/libssl.a 
$ gem install puma -- --with-ssl=/Users/home/sandbox/usr/bin/openssl
$ gem install puma -- --with-ssl=/Users/home/sandbox/usr/bin
$ gem install puma -- --with-opt-dir=/Users/home/sandbox/usr

but got the same error in each case. 但在每种情况下都有相同的错误。 Can someone clue me in to what I'm missing? 有人可以提示我我所缺少的吗?

more info... 更多信息...

The mkmf.log file with the error looks like this (line breaks added for readability): 出现错误的mkmf.log文件如下所示(添加了换行符以提高可读性):

"clang -o conftest 
-I/Users/home/sandbox/usr/include/ruby-2.1.0/x86_64-darwin14.0 
-I/Users/home/sandbox/usr/include/ruby-2.1.0/ruby/backward 
-I/Users/home/sandbox/usr/include/ruby-2.1.0 
-I.  
-I/Users/home/sandbox/usr/include 
-D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    
-O3 -fno-fast-math -ggdb3 -Wall -Wextra 
-Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers 
-Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement 
-Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wextra-tokens  
-fno-common -pipe conftest.c  
-L. 
-L/Users/home/sandbox/usr/lib 
-L/Users/home/sandbox/usr/lib 
-L. -fstack-protector 
-L/Users/home/sandbox/usr/lib      
-lruby.2.1.0 -lssl  -lpthread -ldl -lobjc "

conftest.c:13:57: error: use of undeclared identifier 'SSL_CTX_new'

int t(void) { void ((*volatile p)()); p = (void ((*)()))SSL_CTX_new; return 0; }

As I grovel through my sandbox directory tree, the only header file that defines SSL_CTX_new is ~/sandbox/include/openssl/ssl.h . 当我浏览沙箱目录树时,唯一定义SSL_CTX_new的头文件是~/sandbox/include/openssl/ssl.h It appears that that file isn't being included, and I'm currently at a loss as to why. 似乎该文件未包含在内,而我目前不知道为什么。

For people who are having issues with puma and openssl, particularly with Mac OS 10.11 (El Capitan), adding some flags will save you hours and hours of heartache: 对于使用puma和openssl尤其是Mac OS 10.11(El Capitan)有问题的人,添加一些标志可以节省您数小时的心痛:

gem install puma -- --with-cppflags=-I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib

https://gist.github.com/edvinasbartkus/0e99ea8305a20737f562 https://gist.github.com/edvinasbartkus/0e99ea8305a20737f562

Turns out this was a bug in puma versions 2.9.2+ and has been fixed in version 2.11.0. 原来,这是puma 2.9.2+版中的错误,并已在2.11.0版中修复。 For details, see https://github.com/puma/puma/issues/627 and https://github.com/puma/puma/pull/628 . 有关详细信息,请参见https://github.com/puma/puma/issues/627https://github.com/puma/puma/pull/628

(Note to unix users: if you're still having trouble, make sure you've have libssl-dev installed first.) (对Unix用户的提示:如果仍然遇到问题,请确保首先安装了libssl-dev。)

I had a similar issue on OSx El Capitan. 我在OSx El Capitan上也遇到过类似的问题。 Here's what has helped me: 这对我有帮助:

brew install openssl
brew link --force openssl

Was your Ruby installation definitely configured with --with-openssl-dir ? 您的Ruby安装是否肯定使用--with-openssl-dir配置? (Usually a not-fun part of the process.) You can require 'openssl' ? (通常是过程中不那么有趣的部分。)您可以require 'openssl'吗?

I'm able to install puma with a similar configuration without any flags. 我可以安装具有类似配置的puma,没有任何标志。 (And I think having OpenSSL installed under your home directory is a wise decision.) (而且我认为在您的主目录下安装OpenSSL是一个明智的决定。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM