2016-11-28 87 views
0

當我嘗試使用安裝引入nokogiri:如何在Mac OS約塞米蒂安裝引入nokogiri

gem install nokogiri 

我得到這個錯誤:

ERROR: While executing gem ... (Errno::EACCES) 
Permission denied @ rb_sysopen - /usr/local/lib/ruby/gems/2.3.0/gems/nokogiri-1.6.8.1/.autotest 

我跑了這兩個命令的第一:

gem update --system 
xcode-select --install 

任何人都可以看到這裏有什麼問題嗎?

如果我運行使用sudo這個我得到:

ERROR: Error installing nokogiri: 
ERROR: Failed to build gem native extension. 

current directory: /usr/local/lib/ruby/gems/2.3.0/gems/nokogiri-1.6.8.1/ext/nokogiri 
/usr/local/opt/ruby/bin/ruby -r ./siteconf20161127-35515-164lnl6.rb extconf.rb 
checking if the C compiler accepts ... *** extconf.rb failed *** 
Could not create Makefile due to some reason, probably lack of necessary 
libraries and/or headers. 

和這裏的日誌文件:

"clang -o conftest -I/usr/local/Cellar/ruby/2.3.3/include/ruby-2.3.0/x86_64-darwin14 -I/usr/local/Cellar/ruby/2.3.3/include/ruby-2.3.0/ruby/backward -I/usr/local/Cellar/ruby/2.3.3/include/ruby-2.3.0 -I. -I/usr/local/opt/libyaml/include -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/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/usr/local/Cellar/ruby/2.3.3/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -lruby.2.3.0 -lpthread -ldl -lobjc " 
Undefined symbols for architecture x86_64: 
    "start", referenced from: 
    implicit entry/start for main executable 
ld: symbol(s) not found for architecture x86_64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 
checked program was: 
/* begin */ 
1: #include "ruby.h" 
2: 
3: int main(int argc, char **argv) 
4: { 
5: return 0; 
6: } 
/* end */ 

回答

0

你可以試着這樣做:

gem install nokogiri -v '1.6.8.1' -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2 
0

所以這關成爲權限和文件所有權的混合體。一旦整理完畢,我只需重新運行gem install並關閉,然後在運行rails -v之前重新打開終端。