微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ruby-on-rails – 无法在OSX 10.11.3上安装Puma gem

我只是重新格式化我的MacBook,然后尝试克隆我的Rails项目.当我进行捆绑安装时,Puma gem失败了.

当我运行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.

我该怎么办?

关于我的项目和我的环境:

> Ruby:2.2.0(我正在使用RVM)
> Rails:4.2.0
> OSX:10.11.3

解决方法

而不是按照Zulhilmi Zainudin的建议强制连接openssl(根据此 Github Opened issue不推荐),
我推荐以下基于Puma源代码问题783的解决方案(参考下面).
我正在使用El Capitan(10.11)和openssl通过Homebrew安装:

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

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

但是如果你想让它适用于你所有的Gemfiles,你仍然可以:

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

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

输出应该是:

BUNDLE_BUILD__PUMA:“ – with-opt-dir = /usr/local / opt / openssl”

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

原文地址:https://www.jb51.cc/ruby/269584.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐