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

时间:2016-07-11 14:14:20

标签: ruby-on-rails installation ruby-on-rails-5

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

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 VERSION:2.3.0p0。 RUBYGEMS版本:2.5.1

xcode-select已成功安装。

谢谢!

3 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:0)

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

gem install nokogiri --use-system-libraries

然后我管理了安装rails而没有错误。

答案 2 :(得分:0)

我安装了新版本的rbenv(和ruby),使用任何您想要的版本

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

我更新了我的宝石

gem update --system

然后能够安装滑轨而不会出现此nokogiri错误

gem install rails