【问题标题】:Unable to reinstall Rails无法重新安装 Rails
【发布时间】:2016-07-14 07:26:06
【问题描述】:

我决定按照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

谁能提供可行的替代解决方案?

提前谢谢你!

【问题讨论】:

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


    【解决方案1】:

    安装 brew 库

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

    然后链接你的新 iconv 库:

    brew link libiconv
    

    然后安装你的 gem

    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
    

    【讨论】:

    • 您好 Mohammad,感谢您的快速回复!这是我在运行您的解决方案时得到的输出: > brew tap homebrew/dupes 'Warning: Tap homebrew/dupes already tap.' > brew install libxml2 libxslt '警告:libxml2-2.9.3 已安装' '警告:libxslt-1.1.28_1 已安装' > brew install libiconv ' homebrew/dupes/libiconv-1.14 已安装' > sudo gem update --system
    • /specification.rb:17:in require': cannot load such file -- stringio (LoadError) from /Users/parkour/.rvm/rubies/ruby-2.0.0- /specification.rb:17:in ' 来自 /Users/parkour/.rvm/rubies/ruby-2.0.0- /2.0.0/rubygems。 rb:1291:in require' from /Users/parkour/.rvm/rubies/ruby-2.0.0-site_ruby/2.0.0/rubygems.rb:1291:in ' 来自 /Users/parkour/.rvm/rubies/ruby-2.0.0-site_ruby/2.0.0/rubygems.rb:116:in <top (required)>' from <internal:gem_prelude>:1:in require' 来自:1:in `'
    • 然后链接您的新 iconv 库: brew link libiconv 然后安装您的 gem gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14
    • 创建了 16 个符号链接。但是,即使我运行 ,我仍然会收到以前的错误
    【解决方案2】:

    [29.03.16 更新]:我找不到使用终端/应用程序解决此问题的解决方案,最终进行了备份还原。谢天谢地,我每周都会做一次 Time Machine 备份,所以没有造成真正的伤害。

    再次感谢 Mohammad 的快速建议。

    【讨论】:

      猜你喜欢
      • 2012-09-20
      • 1970-01-01
      • 1970-01-01
      • 2019-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多