Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nokogiri install fails because of missing lzma symbols in self built libxml2 #1119

Closed
dwt opened this issue Jun 25, 2014 · 13 comments
Closed

Comments

@dwt
Copy link

dwt commented Jun 25, 2014

Here's the errors I'm getting:

Undefined symbols for architecture x86_64:
  "_lzma_auto_decoder", referenced from:
      _xz_head in libxml2.a(xzlib.o)
  "_lzma_code", referenced from:
      _xz_decomp in libxml2.a(xzlib.o)
  "_lzma_end", referenced from:
      ___libxml2_xzclose in libxml2.a(xzlib.o)
  "_lzma_properties_decode", referenced from:
      _is_format_lzma in libxml2.a(xzlib.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [xmllint] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

My c is a bit rusty, but I think this means that when nokogiri builds it's own libxml2 it is missing a dependency.

So what to do? If that is the case, another release is probably necessary.

@flavorjones
Copy link
Member

Can you please provide information on the Linux distro you're using and the version of Nokogiri you're trying to install? Also the command line or method you are using to install the gem.

@dwt
Copy link
Author

dwt commented Jun 25, 2014

Sorry, my bad. This is OS X 10.9.3 (13D65) with nokogiri-1.6.2.1 installed via gem install nokogiri (so this should be the latest version).

Do you need any more information?

@cmalek
Copy link

cmalek commented Aug 6, 2014

I'm seeing this same thing on OS X 10.7.5, installing nokogiri-1.6.2.1 via gem install nokogiri.

Any ideas on how to fix this?

@conradwt
Copy link

Has this issue been resolved because I'm similar issue on Ubuntu 14.04 when deploying with Capistrano 3.2.1.? Here's a gist of mkmf.log:

https://gist.github.com/conradwt/bc8beb355b9ebeec17ae

@cmalek
Copy link

cmalek commented Aug 14, 2014

I did end up getting this installed and apparently working with

NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri

But, since I have libxml-2.9.1 installed system wide and the nokogiri specifically states in its installation message that it has included its own libxml-2.8.x because libxml-2.9.x is broken, this seems suboptimal.

I'm going to go with linking against system libraries but I don't know how I'll know if this is going to bite me later.

@lamont-granquist
Copy link

try fixing your homebrew installation of xz:

brew update
brew uninstall xz
brew install xz

if it still doesn't work try brew uninstall xz

@dwt
Copy link
Author

dwt commented Oct 3, 2014

Reinstalling didn't work, but removing xz did the trick and allowed to install nokogiri without any flags. Thanks!

To phrase this problem as a question: Is it a bug in libxml or in the way it's config script is called that it can pick up some references to libxz just because it's on the system?

If there are configure flags for libxml2 that prevent it from looking for libxz, would the nokogiri project want them for the packaged libxml2 package?

@lamont-granquist
Copy link

I'd say this is a homebrew bug. Since libzma exists in /usr/lib/liblzma.5.dylib it is part of the Xcode base install on a Mac. When you install xz you get /usr/local/lib/liblzma.5.dylib and /usr/local/include/lzma.h installed. In contrast when you install libiconv (on an up-to-date homebrew) you get the library and the header files hidden away:

/usr/local/Cellar/libiconv/1.14/include/iconv.h
/usr/local/Cellar/libiconv/1.14/lib/libiconv.2.dylib

In that location those files are available for other homebrew programs to compile and link against but they don't conflict with the system iconv.

When you try to link libiconv into /usr/local/{lib,include} it complains loudly:

% brew link libiconv
Warning: libiconv is keg-only and must be linked with --force
Note that doing so can interfere with building software.
% brew link libiconv --force
Linking /usr/local/Cellar/libiconv/1.14... 16 symlinks created

now we have the have the files in /usr/local:

% ls -la /usr/local/lib/libiconv* /usr/local/include/iconv*
lrwxr-xr-x  1 lamont  wheel  39 Oct  3 09:39 /usr/local/include/iconv.h@ -> ../Cellar/libiconv/1.14/include/iconv.h
lrwxr-xr-x  1 lamont  wheel  44 Oct  3 09:39 /usr/local/lib/libiconv.2.dylib@ -> ../Cellar/libiconv/1.14/lib/libiconv.2.dylib
lrwxr-xr-x  1 lamont  wheel  42 Oct  3 09:39 /usr/local/lib/libiconv.dylib@ -> ../Cellar/libiconv/1.14/lib/libiconv.dylib

and now I broke building nokogiri by brew linking libiconv:

% gem install nokogiri
Building native extensions.  This could take a while...
Building nokogiri using packaged libraries.
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /Users/lamont/.rvm/rubies/ruby-2.1.3/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
checking for iconv.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... no
-----
libiconv is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----

I have to 'brew unlink libiconv' to fix gem installs, which displays precisely the issue that 'brew link libiconv' was yelling at me about. Something similar is likely going on with the liblzma that is packaged in xz.

@flavorjones
Copy link
Member

@zenspider Anything in here that we should add to the OSX installation tutorial?

@conradwt
Copy link

The following worked for me being that Nokogiri 1.6.5 is a dependency for Rails 4.2.0 installation:

installed the current version of Xcode
$ sudo port install libxml2 libxslt
$ bundle config build.nokogiri --use-system-libraries

@zenspider
Copy link
Contributor

@flavorjones yeah. In my experiences helping people get their systems back up and running, removing libiconv from homebrew was sometimes the trick. You might want to add that to the osx/iconv section. I'd push heavily towards plain gem install nokogiri for 90+% of the time. It really does just work and the places where it doesn't are the oddball edge cases. That's what the extra flags are for, not for the normal installs.

@flavorjones
Copy link
Member

I believe #1218 getting merged into master addresses this. Will be in 1.6.7 when it's cut.

If you still have this problem on master, please comment and I'll re-open.

@jorgeboucas
Copy link

this worked for me:

sudo gem install nokogiri -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-iconv-dir=/usr/local/opt/libiconv --with-xml2-dir=/usr/local/opt/libxml2 --with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config --with-xml2-include=/usr/local/opt/libxml2/include/libxml2 --with-xslt-config=/usr/local/opt/libxslt/bin/xslt-config

@sparklemotion sparklemotion locked and limited conversation to collaborators Mar 6, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants