简体   繁体   English

如何在Mac OS Yosemite上安装Nokogiri

[英]How to install Nokogiri on Mac OS Yosemite

When I try to install Nokogiri using: 当我尝试使用以下方法安装Nokogiri时:

gem install nokogiri

I get this error: 我收到此错误:

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

I ran both of these commands first: 我首先运行了这两个命令:

gem update --system
xcode-select --install

Can anyone see what's wrong here? 谁能看到这里有什么问题吗?

If I run this using sudo I get: 如果我使用sudo运行此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.

and here's the log file: 这是日志文件:

"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 */

您可以尝试这样做:

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

So this turned out to be a mix of permissions and file ownership. 因此,事实证明这是权限和文件所有权的组合。 Once that was all sorted out I just had to rerun the gem install and close then reopen the terminal before running rails -v . 解决所有问题后,我只需要重新运行gem install并关闭,然后在运行rails -v之前重新打开终端即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM