Rails/ Yosemite 上的 Nokogiri 安装错误
Rails/ Nokogiri installation errors on Yosemite
将我的 Macbook air 升级到 Yosemite 后,我无法安装 rails。有一连串的错误,其中一些我已经能够解决。当前的错误,我已经工作了几天未能解决,看起来像这样
naomi$ sudo gem install rails
Password:
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/naomi/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150330-94892-1kd8mkt.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
*** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/naomi/.rvm/rubies/ruby-2.2.1/bin/$(RUBY_BASE_NAME)
--help
--clean
--use-system-libraries
/Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- openssl (LoadError)
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/https.rb:22:in `<top (required)>'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:3:in `<top (required)>'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from extconf.rb:395:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0/nokogiri-1.6.6.2/gem_make.out
当我尝试安装 nokogiri 时,我得到
naomi$ gem install nokogiri
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/naomi/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150330-94919-1a0u8fd.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
*** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/naomi/.rvm/rubies/ruby-2.2.1/bin/$(RUBY_BASE_NAME)
--help
--clean
--use-system-libraries
/Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- openssl (LoadError)
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/https.rb:22:in `<top (required)>'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:3:in `<top (required)>'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from extconf.rb:395:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/naomi/.rvm/gems/ruby-2.2.1/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Users/naomi/.rvm/gems/ruby-2.2.1/extensions/x86_64-darwin-14/2.2.0/nokogiri-1.6.6.2/gem_make.out
我是 运行 OSX 10.10.2,ruby -v
给我
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
注意:这可能看起来像是重复的,但我相信它不是:我已经研究了 SO 和其他地方建议的解决方案好几天了,发布的解决方案没有解决错误。 Xcode 已安装,带有开发人员工具,所以 xcode-select --install
给我
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
非常感谢您的帮助!
我在 Nokogiri's site 上发现了一个相关问题(最后一个 post)。他们解决了这个问题:
sudo gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2 --use-system-libraries
问题
出于某种原因,Apple 的 Yosemite 版本 OSX 没有 libxml2 的系统可访问安装。 Nokogiri 需要这个才能编译,幸运的是 Xcode 捆绑了一个 libxml2 版本——我们只需要在安装 gem 时指定它。正确安装 Nokogiri 很重要,因为现在 Rails 4.2.1.rc4 会自动尝试安装它,您会感到痛苦。
修正
gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2
将我的 Macbook air 升级到 Yosemite 后,我无法安装 rails。有一连串的错误,其中一些我已经能够解决。当前的错误,我已经工作了几天未能解决,看起来像这样
naomi$ sudo gem install rails
Password:
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/naomi/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150330-94892-1kd8mkt.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
*** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/naomi/.rvm/rubies/ruby-2.2.1/bin/$(RUBY_BASE_NAME)
--help
--clean
--use-system-libraries
/Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- openssl (LoadError)
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/https.rb:22:in `<top (required)>'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:3:in `<top (required)>'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from extconf.rb:395:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0/nokogiri-1.6.6.2/gem_make.out
当我尝试安装 nokogiri 时,我得到
naomi$ gem install nokogiri
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/naomi/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150330-94919-1a0u8fd.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
*** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/naomi/.rvm/rubies/ruby-2.2.1/bin/$(RUBY_BASE_NAME)
--help
--clean
--use-system-libraries
/Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- openssl (LoadError)
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/net/https.rb:22:in `<top (required)>'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:3:in `<top (required)>'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
from /Users/naomi/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
from extconf.rb:395:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/naomi/.rvm/gems/ruby-2.2.1/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Users/naomi/.rvm/gems/ruby-2.2.1/extensions/x86_64-darwin-14/2.2.0/nokogiri-1.6.6.2/gem_make.out
我是 运行 OSX 10.10.2,ruby -v
给我
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
注意:这可能看起来像是重复的,但我相信它不是:我已经研究了 SO 和其他地方建议的解决方案好几天了,发布的解决方案没有解决错误。 Xcode 已安装,带有开发人员工具,所以 xcode-select --install
给我
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
非常感谢您的帮助!
我在 Nokogiri's site 上发现了一个相关问题(最后一个 post)。他们解决了这个问题:
sudo gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2 --use-system-libraries
问题
出于某种原因,Apple 的 Yosemite 版本 OSX 没有 libxml2 的系统可访问安装。 Nokogiri 需要这个才能编译,幸运的是 Xcode 捆绑了一个 libxml2 版本——我们只需要在安装 gem 时指定它。正确安装 Nokogiri 很重要,因为现在 Rails 4.2.1.rc4 会自动尝试安装它,您会感到痛苦。
修正
gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2