Error - "gem install rails" - libxml2 is missing Error - "gem install rails" - libxml2 is missing ruby-on-rails ruby-on-rails

Error - "gem install rails" - libxml2 is missing


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


You don't have the required library, and it is so easy to google solution:

 brew install libxml2


Try using this:

sudo gem install rails -- --use-system-libraries --with-xml=/usr/local/Cellar/libxml2/