Gem :: Ext :: BuildError:错误:无法为Puma Gem构建gem原生扩展

时间:2016-03-03 23:11:30

标签: ruby-on-rails macos

我已将我的ruby项目从Linux(使用RVM)导入MacOSX(rbenv)。两者都使用相同版本的rails&红宝石。当我按照GoRails指南在两台机器上安装RoR时。

因为我已经将sample_app从Linux导入到MacOSX,所以我运行了bundle install。我安装了大量的宝石近50-100但这个失败了。我不知道它为什么会失败。对我来说,它似乎无法编译一些c文件,但我不知道如何解决这些错误。感谢

Installing puma 2.11.1 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/local/var/rbenv/versions/2.2.3/bin/ruby -r ./siteconf20160304-50117-b8gsxw.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);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/var/rbenv/versions/2.2.3/include/ruby-2.2.0/ruby/intern.h:796:20: note: expanded from macro 'rb_str_new'
        rb_str_new_static((str), (len)) : \
                          ^~~~~
/usr/local/var/rbenv/versions/2.2.3/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);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/var/rbenv/versions/2.2.3/include/ruby-2.2.0/ruby/intern.h:797:13: note: expanded from macro 'rb_str_new'
        rb_str_new((str), (len));         \
                   ^~~~~
/usr/local/var/rbenv/versions/2.2.3/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:
/usr/local/var/rbenv/versions/2.2.3/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 /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/puma-2.11.1 for inspection.
Results logged to /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-15/2.2.0-static/puma-2.11.1/gem_make.out

4 个答案:

答案 0 :(得分:21)

你需要自制软件和openssl。然后运行brew install openssl bundle config build.puma --with-opt-dir=/usr/local/opt/openssl

然后运行bundle install应该有效。

相关问题:https://github.com/puma/puma/issues/718

答案 1 :(得分:1)

如果您使用的是ubuntu 14.04的任何升级版本,并且已在系统中安装了OpenSSL,则只需运行这些命令即可。

首先,只需获取通常安装OpenSSL的位置,即可将其安装在/ usr / bin / openssl位置(如果已安装在单独的位置),请首先使用

 sudo find / -name openssl

然后

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

然后

bundle install 

除非您在路径中安装的OpenSSL正确,否则它将成功

如果尚未使用

安装OpenSSL,则尚未安装
sudo apt-get install openssl

它将完全正常工作。 干杯

答案 2 :(得分:1)

在ubuntu上安装openssl ruby​​-openssl和libssl-dev最终帮助了我。

  

apt-get install openssl ruby​​-openssl libssl-dev

答案 3 :(得分:0)

嘿,您是否尝试使用以下标志安装 gem?

-- --with-cflags="-Wno-error=implicit-function-declaration"