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

Install on Mac OSx with MacPorts fails to find libxml2 #972

Closed
JESii opened this issue Sep 19, 2013 · 18 comments
Closed

Install on Mac OSx with MacPorts fails to find libxml2 #972

JESii opened this issue Sep 19, 2013 · 18 comments

Comments

@JESii
Copy link

JESii commented Sep 19, 2013

Short output from gem install nokogiri is:

Extracting libxml2-2.8.0.tar.gz into
tmp/x86_64-apple-darwin12/ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... OK
Running 'compile' for libxml2 2.8.0... OK
Running 'install' for libxml2 2.8.0... OK
Activating libxml2 2.8.0 (from
/Users/jseidel/.rvm/gems/ruby-1.9.3-p327@rails3213/gems/nokogiri-1.6.0/ports
/x86_64-apple-darwin12/libxml2/2.8.0)...
Extracting libxslt-1.1.26.tar.gz into
tmp/x86_64-apple-darwin12/ports/libxslt/1.1.26... OK
Running 'configure' for libxslt 1.1.26... OK
Running 'compile' for libxslt 1.1.26... OK
Running 'install' for libxslt 1.1.26... OK
Activating libxslt 1.1.26 (from
/Users/jseidel/.rvm/gems/ruby-1.9.3-p327@rails3213/gems/nokogiri-1.6.0/ports
/x86_64-apple-darwin12/libxslt/1.1.26)...
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... yes
checking for xmlParseDoc() in -lxml2... no

-----

libxml2 is missing.  please visit
http://nokogiri.org/tutorials/installing_nokogiri.html for help with
installing dependencies.

However, MacPorts says that's already installed:

port installed | grep lib
libxml @1.8.17_0 (active)
libxml2 @2.9.1_0 (active)

What in the heck is going on here? It seems really weird to me that the
installer is compiling libxml2 and then can't find it!

I've followed the installation instructions at Nokigiri Installation and
that doesn't help. I also tried installing 1.5.9 and that failed the same way.

I've upgraded all ports, upgraded MacPorts...

@knu
Copy link
Member

knu commented Sep 20, 2013

As you see from the output, the gem has freshly built libxml-2.8.0 and tries to use it for building nokogiri.so instead of the one installed by MacPorts. (libxml2 2.9.x is not yet supported by the way)

You have to check out config.log for the reason why it is failing. It might be due to some unfortunate contradiction, like the 2.9.1 library somehow being linked while using the 2.8.0 headers, but that's just a wild guess after all.

@ajsharp
Copy link

ajsharp commented Sep 28, 2013

I'm having a similar problem with homebrew.

@knu
Copy link
Member

knu commented Oct 22, 2013

I've merged the static_clean branch, so the game has changed. Please recheck with the current master.

@thomasdarde
Copy link

I had some problems installing nokogiri. Resulted I was on a "noexec" partiction.
I add this information here, because this ticket shows a very similar error message and i found it while googling for my problem..

@ajsharp
Copy link

ajsharp commented Nov 4, 2013

In my case, the solution was to remove some of the symlinks that existed either at /usr/lib or /usr/local/lib. Homebrew manages /usr/local/lib, and I think /usr/lib is managed by OS X. Either way, when I wiped out what existed for libxml at the /usr/local/lib level, everything worked peachy. So my solution was to use the libxml libraries installed by the OS.

@knu
Copy link
Member

knu commented Nov 5, 2013

As I said, you guys have to show us some configure.log, mkmf.log or whatever log the build is failing at for further investigation. Me too's do not help much.

In this case, the build is failing in trying to find xmlParseDoc() in libxml2, so you should look through mkmf.log for the actual error the compiler or linker emits and the flags given.

@zenspider
Copy link
Contributor

I suspect this should be closed.

@flavorjones
Copy link
Member

I believe the current installation tutorial has correct and up-to-date instructions for OSX:

http://www.nokogiri.org/tutorials/installing_nokogiri.html

Please let me know if you feel it's missing information or is inaccurate. Thank you!

@petertorelli
Copy link

Frustrated that it is Feb 2015 I'm having all the same problems with xml2/xslt that these issues from 2013 brought up. I've used -dir/-lib/-config, and watched gems buld xml2 then fail to locate it a few lines later, and I've had to update zlib/iconv to +universal due to linker errors trying to pull in i386 symbols even though my arch is x86_64. port/brew/ruby all updated. Neither of my config.log files for xml2/xslt have errors.

How does the make process patch libxml2, say it's OK, then fail to find it a few steps later?

Tool versions

~ % port version
Version: 2.3.3
~ % gem --version
2.4.6
~ % xcode-select --version
xcode-select version 2339.
~ % brew -v
Homebrew 0.9.5
~ % ruby --version
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

Ports installed versions...

~ % sudo port installed libxml2 libxslt zlib libiconv
The following ports are currently installed:
  libiconv @1.14_0
  libiconv @1.14_0+universal (active)
  libxml2 @2.9.2_1 (active)
  libxslt @1.1.28_0 (active)
  zlib @1.2.8_0
  zlib @1.2.8_0+universal (active)

Build log:

~ % sudo gem install nokogiri |& tee nokogiri.log
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
        ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150226-63935-nn1m5m.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.2
with the following patches applied:
        - 0001-Revert-Missing-initialization-for-the-catalog-module.patch
        - 0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.2.tar.gz into tmp/x86_64-apple-darwin14/ports/libxml2/2.9.2... OK
Running patch with /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch...
Running 'patch' for libxml2 2.9.2... OK
Running patch with /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch...
Running 'patch' for libxml2 2.9.2... OK
Running 'configure' for libxml2 2.9.2... OK
Running 'compile' for libxml2 2.9.2... OK
Running 'install' for libxml2 2.9.2... OK
Activating libxml2 2.9.2 (from /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/x86_64-apple-darwin14/libxml2/2.9.2)...
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxslt-1.1.28
with the following patches applied:
        - 0001-Adding-doc-update-related-to-1.1.28.patch
        - 0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch
        - 0003-Initialize-pseudo-random-number-generator-with-curre.patch
        - 0004-EXSLT-function-str-replace-is-broken-as-is.patch
        - 0006-Fix-str-padding-to-work-with-UTF-8-strings.patch
        - 0007-Separate-function-for-predicate-matching-in-patterns.patch
        - 0008-Fix-direct-pattern-matching.patch
        - 0009-Fix-certain-patterns-with-predicates.patch
        - 0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch
        - 0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch
        - 0014-Fix-for-bug-436589.patch
        - 0015-Fix-mkdir-for-mingw.patch

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install
************************************************************************
Extracting libxslt-1.1.28.tar.gz into tmp/x86_64-apple-darwin14/ports/libxslt/1.1.28... OK
Running patch with /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0001-Adding-doc-update-related-to-1.1.28.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0003-Initialize-pseudo-random-number-generator-with-curre.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0004-EXSLT-function-str-replace-is-broken-as-is.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0006-Fix-str-padding-to-work-with-UTF-8-strings.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0007-Separate-function-for-predicate-matching-in-patterns.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0008-Fix-direct-pattern-matching.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0009-Fix-certain-patterns-with-predicates.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0014-Fix-for-bug-436589.patch...
Running 'patch' for libxslt 1.1.28... OK
Running patch with /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/patches/libxslt/0015-Fix-mkdir-for-mingw.patch...
Running 'patch' for libxslt 1.1.28... OK
Running 'configure' for libxslt 1.1.28... OK
Running 'compile' for libxslt 1.1.28... OK
Running 'install' for libxslt 1.1.28... OK
Activating libxslt 1.1.28 (from /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/x86_64-apple-darwin14/libxslt/1.1.28)...
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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/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

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-14/2.0.0/nokogiri-1.6.6.2/gem_make.out

Six hours of banging on this. Either I'm missing something totally obvious or I've got a lot of re-installing to do. Any help greatly appreciated.

@zenspider
Copy link
Contributor

@petertorelli I suspect you're going to continue to be frustrated considering you're piggybacking on a closed issue.

@thomasdarde
Copy link

Why using port to install libxml and not brew ?

https://sigilium.com/signatures/rcDC_ix8fTp6sz8EERs4GCcz41fX0rc/link

Le 26 févr. 2015 à 20:19, Ryan Davis [email protected] a écrit :

@petertorelli https://github.com/petertorelli I suspect you're going to continue to be frustrated considering you're piggybacking on a closed issue.


Reply to this email directly or view it on GitHub #972 (comment).

@flavorjones
Copy link
Member

Please make sure you've followed instructions from the nokogiri.org
tutorial and then open a new issue if you are still having issues.

Hint: you shouldn't have to install libxml/libxslt.
On Feb 26, 2015 11:52 AM, "Thomas Darde" [email protected] wrote:

Why using port to install libxml and not brew ?

https://sigilium.com/signatures/rcDC_ix8fTp6sz8EERs4GCcz41fX0rc/link

Le 26 févr. 2015 à 20:19, Ryan Davis [email protected] a écrit
:

@petertorelli https://github.com/petertorelli I suspect you're going
to continue to be frustrated considering you're piggybacking on a closed
issue.


Reply to this email directly or view it on GitHub <
#972 (comment)
.


Reply to this email directly or view it on GitHub
#972 (comment)
.

@petertorelli
Copy link

@flavorjones Thanks Mike. I originally started off with the official instructions on the nokogiri.org website, top to bottom, tried everything. Then ventured off into google search reading about the same issue on places like stackoverflow pages. I'll tabula rasa my system and start from the top again and see what happens. (I realize the two libs can be built as part of the make process, or supplied from the OS. I tried both paths as shown on the .org page.)

@matadon
Copy link

matadon commented Jun 7, 2015

Just in case other people run into this, the command for installing Nokogiri against Macports is:

gem install nokogiri -- --use-system-libraries --with-xml2-config=/opt/local/bin/xml2-config --with-xslt-config=/opt/local/bin/xslt-config

@frmbelz
Copy link

frmbelz commented Feb 4, 2016

Had exact same error as @petertorelli. Looks I did not have libxslt/libxml2 installed through macports ('port installed | grep lib' did not return them), but had symlinks in /usr/lib. Installing through brew did not work. Installed both through 'port install libxslt'. Then @matadon command did install nokogiri

gem install nokogiri -- --use-system-libraries --with-xml2-config=/opt/local/bin/xml2-config --with-xslt-config=/opt/local/bin/xslt-config

Thanks much

@thomasdarde
Copy link

Hello , why are you still using macports ? Is their a specific reason ?
I invite you to take the time to replace it with http://brew.sh/

@JESii
Copy link
Author

JESii commented Feb 5, 2016

FYI... I switched to homebrew quite some time ago; much better than ports, IMO.

@zenspider
Copy link
Contributor

@flavorjones please lock this one down.

Others: not helping.

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

No branches or pull requests

9 participants