无法重新安装Rails

时间:2016-03-26 17:39:09

标签: ruby-on-rails ruby-on-rails-4

我决定在install Rails Guide之后在我的Mac上重新安装Rails,但在尝试gem install nokogiri时失败了。我正在运行Mac OSX版本10.10.5并且当前安装了ruby版本2.2.1p85。

我收到以下错误:

Running git apply with /Users/parkour/.rvm/gems/ruby-2.0.0-p643/gems/nokogiri-1.6.7.2/patches/libxslt/0017-Updated-config.guess.patch... OK
Running 'configure' for libxslt 1.1.28... OK
Running 'compile' for libxslt 1.1.28... OK
Running 'install' for libxslt 1.1.28... OK
Activating libxslt 1.1.28 (from /Users/parkour/.rvm/gems/ruby-2.0.0-p643/gems/nokogiri-1.6.7.2/ports/x86_64-apple-darwin14.1.0/libxslt/1.1.28)...
checking for main() in -llzma... yes
checking for xmlParseDoc() in libxml/parser.h... no
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
-----
libxml2 is missing.  Please locate mkmf.log to investigate how it is failing.
-----
*** 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.

到目前为止,我已尝试以下命令但未成功:

brew install libxml2
     

(建议here

xcode-select --install
gem install nokogiri 
bundle config build.nokogiri --use-system-libraries
bundle install
     

(建议here

brew install libxml2 libxslt libiconv
NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"

ARCHFLAGS="-arch x86_64" gem install nokogiri
     

(均建议here

任何人都可以提供可行的替代解决方案吗?

提前谢谢!

2 个答案:

答案 0 :(得分:0)

安装brew libs

brew tap homebrew/dupes
brew install libxml2 libxslt
brew install libiconv

然后链接你的新iconv libs:

brew link libiconv

然后安装你的宝石

gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14

如果它不起作用,那么你可以试试这个。我不确定,但它可能会奏效。

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

答案 1 :(得分:0)

[2006年3月29日更新]:我找不到使用终端/应用程序解决此问题的解决方案,最终进行了备份恢复。值得庆幸的是,我每周都会进行Time Machine备份,因此没有真正的伤害。

再次感谢穆罕默德的快速建议。