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 instal
It worked for me as Simar has mentioned.
sudo gem install rails -- --use-system-libraries --with-xml=/usr/local/Cellar/libxml2/
And if you were having troubles install it on Mac please check out here. https://gorails.com/setup/osx/10.11-el-capitan
Also if you could not find /usr/local/Cellar/libxml2/ existing, you may need to homebrew it.
brew install libxml2
If you are installing it on a newly installed OS X EL CAPITAN as I do, you probably find homebrew telling you that libxml2 is installed already and brew will not replace the existing libxml2 with it's newly installed one which is at /usr/local/Cellar/libxml2/, which is the one we really should link the libraries to. Since the system default libxml2 would not link successfully.