简体   繁体   English

无法在OSX 10.11.3上安装Puma gem

[英]Can't install Puma gem on OSX 10.11.3

I just reformat my MacBook and I try to clone of my Rails project. 我只是重新格式化了MacBook,然后尝试克隆我的Rails项目。 When I do bundle install , Puma gem failed. 当我进行bundle install ,Puma gem失败了。

When I run gem install puma -v '2.13.4' , I get this error: 当我运行gem install puma -v '2.13.4' ,出现以下错误:

Fetching: puma-2.13.4.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing puma:
    ERROR: Failed to build gem native extension.

    /Users/zulhilmi/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20160211-95547-1pdaoaq.rb extconf.rb
checking for BIO_read() in -lcrypto... yes
checking for SSL_CTX_new() in -lssl... yes
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling http11_parser.c
compiling io_buffer.c
io_buffer.c:119:10: warning: passing 'uint8_t *' (aka 'unsigned char *') to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]
  return rb_str_new(b->top, b->cur - b->top);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/zulhilmi/.rvm/rubies/ruby-2.2.0/include/ruby-2.2.0/ruby/intern.h:796:20: note: expanded from macro 'rb_str_new'
        rb_str_new_static((str), (len)) : \
                          ^~~~~
/Users/zulhilmi/.rvm/rubies/ruby-2.2.0/include/ruby-2.2.0/ruby/intern.h:727:37: note: passing argument to parameter here
VALUE rb_str_new_static(const char *, long);
                                    ^
io_buffer.c:119:10: warning: passing 'uint8_t *' (aka 'unsigned char *') to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]
  return rb_str_new(b->top, b->cur - b->top);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/zulhilmi/.rvm/rubies/ruby-2.2.0/include/ruby-2.2.0/ruby/intern.h:797:13: note: expanded from macro 'rb_str_new'
        rb_str_new((str), (len));         \
                   ^~~~~
/Users/zulhilmi/.rvm/rubies/ruby-2.2.0/include/ruby-2.2.0/ruby/intern.h:706:29: note: passing argument to parameter here
VALUE rb_str_new(const char*, long);
                            ^
2 warnings generated.
compiling mini_ssl.c
In file included from mini_ssl.c:3:
/Users/zulhilmi/.rvm/rubies/ruby-2.2.0/include/ruby-2.2.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
mini_ssl.c:4:10: fatal error: 'openssl/bio.h' file not found
#include <openssl/bio.h>
         ^
1 warning and 1 error generated.
make: *** [mini_ssl.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/zulhilmi/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/puma-2.13.4 for inspection.

What should I do? 我该怎么办?

About my project and my environment: 关于我的项目和环境:

  • Ruby: 2.2.0 (I'm using RVM) Ruby:2.2.0(我正在使用RVM)
  • Rails: 4.2.0 导轨:4.2.0
  • OSX: 10.11.3 OSX:10.11.3

Instead of force linking openssl(which is NOT recommended according to this Github Opened issue ) as proposed by Zulhilmi Zainudin, I recommend the following solution based on issue 783 of Puma source code(reference below). 我不是按照Zulhilmi Zainudin的建议强制链接openssl(根据此Github Opened问题 建议这样做),我建议根据Puma源代码的问题783(以下参考)提出以下解决方案。
I'm using El Capitan (10.11) with openssl installed via Homebrew: 我正在使用El Capitan(10.11),并通过Homebrew安装了openssl:

$ gem install puma -v 2.13.4 -- --with-opt-dir=/usr/local/opt/openssl

Reference: https://github.com/puma/puma/issues/783 参考: https : //github.com/puma/puma/issues/783

But if you want to make it work for all your Gemfiles you can still: 但是,如果您想使其适用于所有Gemfile,您仍然可以:

$ bundle config build.puma --with-opt-dir=/usr/local/opt/openssl

and confirm: 并确认:
$ grep PUMA ~/.bundle/config

the output should be: 输出应为:

BUNDLE_BUILD__PUMA: "--with-opt-dir=/usr/local/opt/openssl"

Reference: https://github.com/puma/puma/issues/718 参考: https : //github.com/puma/puma/issues/718

This solution works for me: 此解决方案适用于我:

brew install openssl
brew link --force openssl

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

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