Error - "gem install rails" - libxml2 is missing

Alvin Jones picture Alvin Jones · Mar 18, 2015 · Viewed 8.3k times · Source

I've been working through the Rails install instructions (http://railsapps.github.io/installrubyonrails-mac.html) and everything was okay up until I got to gem install rails part under New Rails Application. When I ran that I got libxml2 is missing. Here's the log: http://codecascade.com/sIjhQ/raw

I had similar issues install nokogiri, and the only way I was able to get it resolved was with

gem install nokogiri -- --use-system-libraries

I'm on OS X 10.10.2. I also have RubyMine installed if that's potentially relevant.

Answer

NotYanka picture NotYanka · Mar 20, 2015

I just had the same problem and was able to solve it as follows:

Installing Nokogiri separately worked only when using the system libraries:

gem install nokogiri -- --use-system-libraries

...but was still failing when executing bundle install. So just configure bundler to also build Nokogiri using the system libraries:

bundle config build.nokogiri --use-system-libraries