Error - "gem install rails" - libxml2 is missing
Asked Answered
O

8

8

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.

Overwrite answered 18/3, 2015 at 6:21 Comment(3)
possible duplicate of Libxml2 missing mac os x 10.10Kandrakandy
Please don't link to information that is relevant to the problem. Asking people to chase down information in the installation log on another site only discourages potential help. Plus when the link breaks your question will be missing useful information. Instead, summarize that information in your question.Bulldog
ping back might help someone (including my future self) github.com/termux/termux-packages/issues/…Venturesome
L
7

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
Lurid answered 20/3, 2015 at 11:3 Comment(0)
E
6

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

 brew install libxml2
Epiblast answered 18/3, 2015 at 10:36 Comment(5)
You understand this requires the OP to use/install homebrew, right? I don't know about them, but I don't like to run that type of third party package manager on my mac. Especially not to get one single library. And I've never had to in order to get rails working.Falconet
@DaveMunger nokogiri required libxml2 - so you do not wanna install libxml2? You can't use nokogiri. OP said, that he on OS X 10.10.2. Home brew - most popular service for search-n-install libs like that.Epiblast
I said I didn't want to install homebrew. You can install libxml2 without using homebrew. I can't tell if you are being sarcastic or not in this reply, but your tone in your original answer is just a little bit judgmental. Different people approach things different ways and we can all get along. :) Edit: I forgot to say, I've installed libxml2 on a mac a few times already without resorting to using homebrew.Falconet
@DaveMunger oh, sorry, now i get what you mean. But i thunk that sometimes - most popular solution - best solution (for juniors) because junior have trouble with select from a lot of opinions, if he know nothing about every opinion. So usually my plan is 1) You have to use A and then answer to questions like "what is A?" "how i install A?" "Is there other solutions except A?". Maybe i am wrong. It only my theory. I teach students only 1 year course "information systems" at college as a teacherEpiblast
I do agree homebrew is the easiest path if you're okay with installing it.Falconet
H
4

Try using this:

sudo gem install rails -- --use-system-libraries --with-xml=/usr/local/Cellar/libxml2/
Hypethral answered 22/3, 2015 at 23:31 Comment(1)
I get an error: Operation not permitted - /usr/bin/sprocketsLilia
S
1

I had the same issue, on Debian it seemed only a problem of missing 'dev' libraries, probably needed to compile sources during installation (I'm guessing). I solved it by installing (via apt-get or aptitude) the following packages:

  • Libxml2-dev
  • Libxslt1-dev
Sternutatory answered 4/5, 2016 at 21:45 Comment(0)
S
1

This worked for me (based on this Github thread):

gem install nokogiri -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib/

As a note, my issue was:

...
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.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/seanshadmand/.rvm/rubies/ruby-2.1.1/bin/ruby
    --help
    --clean
    --use-system-libraries
    --enable-static
    --disable-static
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --enable-cross-build
    --disable-cross-build
    --with-xml2lib
    --without-xml2lib
    --with-libxml2lib
    --without-libxml2lib

To see why this extension failed to ...

extconf failed, exit code 1
Skylight answered 29/5, 2016 at 16:36 Comment(0)
D
0

For some reason nokogiri build process for libxml2 will misplace build version.

Instead of lib/ it will to go lib64/. Nokogiri will then look for it in the wrong directory.

More info here: https://github.com/sparklemotion/nokogiri/issues/1334

Demission answered 11/11, 2015 at 10:33 Comment(0)
P
0

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.

Phallicism answered 10/4, 2016 at 6:46 Comment(0)
K
0

I had the same problem when I try:

gem install libxml-ruby -v '3.0.0

Run the following solved the issue on Mac for me:

gem update --system

xcode-select --install

gem install nokogiri

See installing nokogiri for more details

Kollwitz answered 11/10, 2017 at 18:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.