0

I'm trying to install the nokogiri gem, but it says:

libxml2 is missing.  Please locate mkmf.log to investigate how it is failing.

When I try to install libxml2 with brew, it says:

Warning: libxml2 2.9.5 is already installed

Earlier, it said that it was installing a keg-only version because the macOS already had a version of libxml2.

So, gem can't find any copies of libxml2, but brew finds 2?

How do I tell gem where to find libxml2?

looking at mkmf.log, I see that it seems to not know about iconv?

have_iconv?: checking for iconv using --with-opt-* flags... -------------------
- yes

"gcc -o conftest -I/Users/brianp/.rvm/rubies/ruby-2.1.10/include/ruby-2.1.0/x86_64-darwin16.0 -I/Users/brianp/.rvm/rubies/ruby-2.1.10/include/ruby-2.1.0/ruby/backward -I/Users/brianp/.rvm/rubies/ruby-2.1.10/include/ruby-2.1.0 -I.  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wextra-tokens  -fno-common -pipe  -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c  -L. -L/Users/brianp/.rvm/rubies/ruby-2.1.10/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib      -lruby.2.1.0  -lpthread -ldl -lobjc  "
Undefined symbols for architecture x86_64:
  "_iconv", referenced from:
      _main in conftest-311f4b.o
  "_iconv_open", referenced from:
      _main in conftest-311f4b.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <stdlib.h>
 4: #include <iconv.h>
 5: 
 6: int main(void)
 7: {
 8:     iconv_t cd = iconv_open("", "");
 9:     iconv(cd, NULL, NULL, NULL, NULL);
10:     return EXIT_SUCCESS;
11: }
/* end */

again, it says I have iconv, but then it crashes?

I must be misunderstanding a message somewhere.

Brian Postow
  • 11,709
  • 17
  • 81
  • 125
  • This is the first result from a google search: `sudo apt-get install libxslt-dev libxml2-dev`. Presumably you'll need to use `brew` since you're using a mac, but you get the idea. – Tom Lord Sep 26 '17 at 15:08
  • 1
    Possible duplicate of [Nokogiri installation fails -libxml2 is missing](https://stackoverflow.com/questions/6277456/nokogiri-installation-fails-libxml2-is-missing) – Tom Lord Sep 26 '17 at 15:09
  • With Homebrew there's a difference between "installed" and actually linked in properly. Check that everything's coherent: `brew doctor`. – tadman Sep 26 '17 at 16:10
  • @tadman If it weren’t linked OP would have gotten a message like "`Warning: libxml2 2.9.5 is already installed, it’s just not linked.`". – bfontaine Sep 27 '17 at 15:31
  • I managed to make this work with rbenv. RMV was causing other larger problems... – Brian Postow Sep 28 '17 at 15:54

0 Answers0