extconf 失败,安装 [Ruby on Rails] 5 on OS X Yosemite 10.10.5 时出现退出代码 1 错误

extconf failed, exit code 1 error when installing [Ruby on Rails] 5 on OS X Yosemite 10.10.5

我正在尝试按照 rails 站点上的说明在 OS X Yosemite 10.10.5 上的 Rails v5 上安装 Ruby :

http://railsapps.github.io/installrubyonrails-mac.html

当我运行这个:

sudo gem install rails --version 5.0.0 --no-ri --no-rdoc

我收到错误 ERROR: Failed to build gem native extension。 以下是我的命令行输出中可能有用的部分内容:

current directory: /Users/me/.rvm/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri

[...]


Running 'compile' for libxml2 2.9.4... ERROR, review '/Users/me/.rvm/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri/tmp/x86_64-apple-da

rwin14.5.0/ports/libxml2/2.9.4/compile.log' to see what happened. Last lines are:

[...]

 1 error generated.
    make[2]: *** [xmlIO.lo] Error 1
    make[1]: *** [all-recursive] Error 1
    make: *** [all] Error 2
    ========================================================================
    *** 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.

[...]

    To see why this extension failed to compile, please check the mkmf.log which can be found here:

      /Users/me/.rvm/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-14/2.3.0/nokogiri-1.6.8/mkmf.log


    extconf failed, exit code 1

这里是 mkmf.log 文件的一部分:

"gcc -o conftest -I/Users/me/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/x86_64-darwin14 -I/Users/me/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/ruby/backward -I/Users/me/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0 -I.  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/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 -Wdeprecated-declarations -Wextra-tokens  -fno-common -pipe  conftest.c  -L. -L/Users/thanos/.rvm/rubies/ruby-2.3.0/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib     -lruby.2.3.0  -lpthread -ldl -lobjc  "
/Users/me/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/mkmf.rb:395: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

我不知道发生了什么:(。有人可以帮忙吗?

RUBY 版本:2.3.0p0。 RUBY宝石版本:2.5.1

xcode-select安装成功

谢谢!

我解决了。 该错误与 nokogiri 有关。我是用--use-system-libraries参数单独安装的:

gem install nokogiri --use-system-libraries

然后我成功地安装了 rails。

http://www.nokogiri.org/tutorials/installing_nokogiri.html 说他们建议使用包含的库安装,而不是使用系统库安装。

所以我尝试(在 Ubuntu 上)按照那里的说明进行操作,并且成功了

sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev
gem install nokogiri

我安装了更新版本的 rbenv(和 ruby),使用您喜欢的任何版本

RUBY_CONFIGURE_OPTS=--with-readline-dir="$(brew --prefix readline)" rbenv install 2.4.0

我更新了我的宝石

gem update --system

然后能够安装 rails 而没有这个 nokogiri 错误

gem install rails

尝试更新 gems:

gem更新--系统