Reputation: 563
After upgrading my Macbook air to Yosemite, I haven't been able to install rails. There's been a whole train of errors, and some of them I've been able to resolve. The current error, which I've been working unsuccessfully for days to resolve, looks like this
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
When I try to install nokogiri, I get
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
I'm running OSX 10.10.2, and ruby -v
gives me
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
Note: this may seem like a duplicate, but I believe it's not: I've been investigating solutions suggested on SO and elsewhere for days, and the posted solutions haven't resolved the error. Xcode is installed, with developer tools, so xcode-select --install
gives me
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
Many thanks in advance for your help!
Upvotes: 1
Views: 726
Reputation: 525
The Problem
For some reason Apple’s Yosemite version of OSX does not have a system accessible installation of libxml2. Nokogiri requires this in order to compile and luckily Xcode has a version of libxml2 bundled with it — we just need to specify it when installing the gem. It’s important to get Nokogiri installed correctly because as of right now Rails 4.2.1.rc4 automatically attempts to install it and you will feel pain.
The Fix
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
Upvotes: 1
Reputation: 1771
I found a related issue (the very last post) on Nokogiri's site.They solved the problem with:
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
Upvotes: 2