0

I'm having a problem installing Ruby on Rails in my terminal.

Has anyone else encountered the following error in the terminal:

checking for main() in -llzma... yes
checking for xmlParseDoc() in libxml/parser.h... no
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
-----
libxml2 is missing.  Please locate mkmf.log to investigate how it is failing.
-----
*** 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.

I'm using the standard bash:

$ gem install rails

How would I go about fixing this? I've tried a few things here on stack exchange but nothing so far has worked...

Using $ brew list in the terminal yields:

Michaels-iMac:~ iMacHome$ brew list
autoconf    libksba     libxslt     pkg-config
automake    libtool     libyaml     readline
libgpg-error    libxml2     openssl
Michaels-iMac:~ iMacHome$

It seems to be there...

GCien
  • 2,221
  • 6
  • 30
  • 56

2 Answers2

4

assuming you have Xcode installed try this

gem install rails -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.‌platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2 --use-system-libraries
lx00st
  • 1,566
  • 9
  • 17
  • he's using RVM, it's better to use the package system of RVM to get the libxml2 library, as that is known to work properly inside the RVM installation. – codingbunny Feb 27 '15 at 14:13
  • This worked, it might be a rvm workaround but it seemed to work. – GCien Feb 27 '15 at 14:17
  • you should try NekoNova's answer as well because its not "rvm way" and you will have to run this wired params with all new gemsets – lx00st Feb 27 '15 at 14:19
2

The problem could be your RVM.

Try either this command:

 rvm cleanup all
 rvm pkg uninstall libxml2
 rvm reinstall all --force

or upgrade/reinstall to the latest RVM installation.

-- To properly install the rails gem globally for a Ruby version:

rvm use <rubyversion>
gem install rails

example to use rails on ruby 2.1.5:

rvm use 2.1.5
gem install rails
codingbunny
  • 3,989
  • 6
  • 29
  • 54