Installing Nokogiri on Osx 10.10 Yosemite

Installing Nokogiri on OSX 10.10 Yosemite

I managed to install Nokogiri under Yosemite (OS X 10.10 Preview).

Step 1: Install Brew

Skip this if brew was installed.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Step 2: Install brew libs

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

Step 3: Download and install Apple Commandline Tools for 10.10

It's important that you need to restart after installation.

Link: command_line_tools_for_osx_10_10_june_2014.dmg

After restarted, you can check installation in Terminal:

> xcode-select --install
-> xcode-select: error: command line tools are already installed, use "Software Update" to install updates

This error means you have commandline tool installed correctly.

Installing Nokogiri

Try using n previous version 1.6.1 in your Gemfile, version 1.6.2.1 has issues currently with "10.10 Preview". It only works with my rbenv Ruby 2.0.0p247, failed to install on 2.1.1. You can give your existing Ruby versions a couple of tries.

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

rails : install nokogiri fails on Mac OSX Yosemite

One of issues was that you were manually installing Nokogiri 1.6.6.2, but not including the nokogiri gem entry in your Gemfile. Bundler will specifically only show your app the gems that are listed in the file.

It wasn't clear to me if you were tied to nokogiri 1.6.1 because it was a dependency of another gem. If there was another gem calling for 1.6.1 then you would investigate a newer version of that gem, which hopefully depended on the newer Nokogiri. bundle update <othergem> would attempt to do so.

Just wanted to be clear that I wasn't suggesting modifying another gem's dependencies in your lock file as they were set for a reason by that gem's author.

Since you initially specified gem 'nokogiri', '~> 1.6.1' in your Gemfile you were locked to that after the first bundle install. bundle update nokogiri would try to update you to the latest. Or manually changing the Gemfile to 1.6.6.2 or more loosely ~> 1.6 or 1.6.6.

Also, as @the Tin Man mentioned using sudo install to put gems into the Apple system ruby isn't the best way to go. I definitely recommend using one of the Ruby version managers like RVM or rbenv as he linked in his comment.

Install Nokogiri on Yosemite

I just did a full installation of Rails and Ruby and everything you need. I followed these steps.

https://gorails.com/setup/osx/10.10-yosemite

and use the following to install nokogiri

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

Failure to install nokogiri libiconv is missing on Yosemite Mac OS X 10.10

The nokogiri install tutorial provides the solution:

# bash
brew unlink gcc
gem uninstall nokogiri
xcode-select --install
gem install nokogiri

If you don't have Xcode 6.1, yet, you may install it from the apple developer download site (section additional tools), as described in this blog post.

How to install Nokogiri on Mac OS Sierra 10.12

Open Xcode and, from the menu XCode -> Preferences update your Command Line Tools (Xcode 8.0).

Then do:

bundle config build.nokogiri --use-system-libraries=true --with-xml2-include="$(xcrun --show-sdk-path)"/usr/include/libxml2
bundle install

or just:

gem install nokogiri -v 1.6.8.1 -- --use-system-libraries=true --with-xml2-include="$(xcrun --show-sdk-path)"/usr/include/libxml2


Related Topics



Leave a reply



Submit