sparklemotion / nokogiri

Nokogiri (鋸) makes it easy and painless to work with XML and HTML from Ruby.
https://nokogiri.org/
MIT License
6.14k stars 897 forks source link

Nokogiri error: Libiconv missing on mavericks #1111

Closed Jaffery5 closed 9 years ago

Jaffery5 commented 10 years ago

I am trying to install nokogiri on maverick and i am unable to do so, even when libiconv is installed through brew:

Installing nokogiri (1.6.2.1) Building nokogiri using packaged libraries.

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-2.0.0-p0/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.
-----
*** 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=/usr/local/rvm/rubies/ruby-2.0.0-p0/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

Gem files will remain installed in /Users/Jaffery/Desktop/helpspree/vendor/bundle/ruby/2.0.0/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /Users/Jaffery/Desktop/helpspree/vendor/bundle/ruby/2.0.0/gems/nokogiri-1.6.2.1/ext/nokogiri/gem_make.out

An error occurred while installing nokogiri (1.6.2.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.2.1'` succeeds before bundling.
flavorjones commented 10 years ago

@knu are you able to investigate this? Or should we hand off to a Mac user? ;)

zenspider commented 10 years ago

Looking...

zenspider commented 10 years ago

It installs fine for me using stock ruby on OSX 10.9.3:

10002 % ruby -v ; gem i -i xxx nokogiri -v '1.6.2.1'
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]
Fetching: mini_portile-0.6.0.gem (100%)
Successfully installed mini_portile-0.6.0
Fetching: nokogiri-1.6.2.1.gem (100%)
Building native extensions.  This could take a while...
Building nokogiri using packaged libraries.
Building libxml2-2.8.0 for nokogiri with the following patches applied:
    - 0001-Fix-parser-local-buffers-size-problems.patch
    - 0002-Fix-entities-local-buffers-size-problems.patch
    - 0003-Fix-an-error-in-previous-commit.patch
    - 0004-Fix-potential-out-of-bound-access.patch
    - 0005-Detect-excessive-entities-expansion-upon-replacement.patch
    - 0006-Do-not-fetch-external-parsed-entities.patch
    - 0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch
    - 0008-Improve-handling-of-xmlStopParser.patch
    - 0009-Fix-a-couple-of-return-without-value.patch
    - 0010-Keep-non-significant-blanks-node-in-HTML-parser.patch
    - 0011-Do-not-fetch-external-parameter-entities.patch
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxml2.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

    gem install nokogiri -- --use-system-libraries

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

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

However, note that nokogiri does not necessarily support all versions
of libxml2.

For example, libxml2-2.9.0 and higher are currently known to be broken
and thus unsupported by nokogiri, due to compatibility problems and
XPath optimization bugs.
************************************************************************
Building libxslt-1.1.28 for nokogiri 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
************************************************************************
IMPORTANT!  Nokogiri builds and uses a packaged version of libxslt.

If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:

    gem install nokogiri -- --use-system-libraries

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

    bundle config build.nokogiri --use-system-libraries
    bundle install
************************************************************************
Successfully installed nokogiri-1.6.2.1
Parsing documentation for mini_portile-0.6.0
Installing ri documentation for mini_portile-0.6.0
Parsing documentation for nokogiri-1.6.2.1
Installing ri documentation for nokogiri-1.6.2.1
Done installing documentation for mini_portile, nokogiri after 5 seconds
2 gems installed
10003 % 

What I need from you:

  1. What version of ruby (ruby -v), and where you got it (rvm, rbenv, stock, etc).
  2. What version of rubygems (gem -v) you're using,
  3. What version of the developer tools (clang -v).
knu commented 10 years ago

Also, what's logged in mkmf.log is essential for further investigation. Please locate it and paste it (in Gist if it's huge).

dmitrytrager commented 10 years ago

Mac OS X 10.9.3 build 13D65 RVM ruby 2.0.0-p481

libiconv 1.14 libxml2 2.8.0 libxslt 1.1.28 installed via homebrew 0.9

Rubygems 2.2.2 Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) Target: x86_64-apple-darwin13.2.0 Thread model: posix


The same problem when install nokogiri v '1.6.2.1'. By the way, with ruby 2.1.1 and nokogiri v '1.6.1' everuthing is fine.

masterkain commented 10 years ago

I can't install either (Yosemite - Xcode 6 Beta as command line tools) without some parameter (bundle install will fail). Ruby 2.1.2

Also tried with brew link libxml2 libxslt libiconv --force same result.

This worked: gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14/

$ brew reinstall libiconv libxml2 libxslt
==> Reinstalling libiconv
==> Downloading http://ftpmirror.gnu.org/libiconv/libiconv-1.14.tar.gz
######################################################################## 100.0%
==> Downloading https://trac.macports.org/export/89276/trunk/dports/textproc/libiconv/files/patch-Makefile.devel
######################################################################## 100.0%
==> Downloading https://trac.macports.org/export/89276/trunk/dports/textproc/libiconv/files/patch-utf8mac.diff
######################################################################## 100.0%
==> Patching
patching file Makefile.devel
Hunk #1 succeeded at 106 (offset 1 line).
patching file lib/converters.h
patching file lib/encodings.def
patching file lib/utf8mac.h
patching file lib/flags.h
==> ./configure --prefix=/usr/local/Cellar/libiconv/1.14 --enable-extra-encodings
==> make -f Makefile.devel CFLAGS= CC=clang
==> make install
==> Caveats
This formula is keg-only, so it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/libiconv/lib
    CPPFLAGS: -I/usr/local/opt/libiconv/include

==> Summary
  /usr/local/Cellar/libiconv/1.14: 26 files, 1.4M, built in 76 seconds
==> Reinstalling libxml2
==> Downloading ftp://xmlsoft.org/libxml2/libxml2-2.9.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/libxml2-2.9.1.tar.gz
==> ./configure --prefix=/usr/local/Cellar/libxml2/2.9.1 --without-python
==> make
==> make install
==> Caveats
This formula is keg-only, so it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/libxml2/lib
    CPPFLAGS: -I/usr/local/opt/libxml2/include

==> Summary
  /usr/local/Cellar/libxml2/2.9.1: 274 files, 11M, built in 40 seconds
==> Reinstalling libxslt
==> Downloading ftp://xmlsoft.org/libxml2/libxslt-1.1.28.tar.gz
Already downloaded: /Library/Caches/Homebrew/libxslt-1.1.28.tar.gz
==> ./configure --prefix=/usr/local/Cellar/libxslt/1.1.28 --with-libxml-prefix=/usr/local/Cellar/libxml2/2.9.1
==> make
==> make install
==> Caveats
To allow the nokogiri gem to link against this libxslt run:
  gem install nokogiri -- --with-xslt-dir=/usr/local/opt/libxslt

This formula is keg-only, so it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/libxslt/lib
    CPPFLAGS: -I/usr/local/opt/libxslt/include

==> Summary
  /usr/local/Cellar/libxslt/1.1.28: 134 files, 3.1M, built in 25 seconds
$ 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/kain/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
-----
libiconv is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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
  --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/kain/.rvm/rubies/ruby-2.1.2/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

extconf failed, exit code 1

Gem files will remain installed in /Users/kain/.rvm/gems/ruby-2.1.2/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /Users/kain/.rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-14/2.1.0/nokogiri-1.6.2.1/gem_make.out
hiremaga commented 10 years ago

I was able to work around this by following the suggestion here http://stackoverflow.com/questions/22352838/ruby-gem-install-json-fails-on-mavericks-and-xcode-5-1-unknown-argument-mul

I've noticed this error on multiple Macs that were upgraded to 10.9.3 and haven't seen it on Macs that begin their lives on 10.9.3 (with only the XCode CLI tools installed). I'm running XCode 5.1.1 (5B1008) on the Mac that experienced the issue.

The specific command that ultimately worked to install Nokogiri under system ruby was:

sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install nokogiri -- --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
allaire commented 10 years ago

@hiremaga Is spot on I think on the new OS X that begin their lives on Mavericks.

I got a new Macbook Air, and I installed Nokogiri without any issues. But when I restored my old Macbook Pro, I wasn't able to install Nokogiri without specifying some hackish paths to libiconv.

What can we do to help pin down this?

zenspider commented 10 years ago

@allaire don't think so. My macbook air started as 10.8 and has since been upgraded to 10.9 and I don't have problems installing.

I did find a problem installing on a virginal OSX 10.9 that I'm tracking down, but it is unrelated to this and looks like it might be a problem with rubygems or some-such.

I need a repro to get further with this. Preferably a repro without rvm. If it requires rvm to repro, then it is a problem with rvm.

@masterkain -- you need to follow the instructions that brew is giving you. It is very specifically spelling out:

To allow the nokogiri gem to link against this libxslt run:
  gem install nokogiri -- --with-xslt-dir=/usr/local/opt/libxslt

This formula is keg-only, so it was not symlinked into /usr/local.
allaire commented 10 years ago

@zenspider If that helps, the laptop that install failed was running with rbenv, not rvm.

Thanks for taking the time to figure this!

zenspider commented 10 years ago

OK. I'll install ruby-build and take a whack at that tomorrow.

hiremaga commented 10 years ago

Fwiw, the machines I've seen this on started off as 10.9 (2.0.0p247 system ruby) and were upgraded to 10.9.3 (2.0.0p451 system ruby).

I'll write back of I get the opportunity to replicate this reliably in a VM.

On Monday, June 23, 2014, Ryan Davis notifications@github.com wrote:

@allaire https://github.com/allaire don't think so. My macbook air started as 10.8 and has since been upgraded to 10.9 and I don't have problems installing.

I did find a problem installing on a virginal OSX 10.9 that I'm tracking down, but it is unrelated to this and looks like it might be a problem with rubygems or some-such.

I need a repro to get further with this. Preferably a repro without rvm. If it requires rvm to repro, then it is a problem with rvm.

@masterkain https://github.com/masterkain -- you need to follow the instructions that brew is giving you. It is very specifically spelling out:

To allow the nokogiri gem to link against this libxslt run: gem install nokogiri -- --with-xslt-dir=/usr/local/opt/libxslt

This formula is keg-only, so it was not symlinked into /usr/local.

— Reply to this email directly or view it on GitHub https://github.com/sparklemotion/nokogiri/issues/1111#issuecomment-46918420 .

danfinnie commented 10 years ago

@masterkain When you used the libiconv formula, was that something that you wrote yourself? It seems like the libiconv formula that used to be distributed with Homebrew was removed in commit ad7020

danfinnie commented 10 years ago

@masterkain Or maybe you were using the homebrew/dupes?

muescha commented 10 years ago

the same issue, can not install it.

the troubleshooting page http://nokogiri.org/tutorials/installing_nokogiri.html shows already to use hombebrew - it should be updated.

Installing nokogiri (1.6.2.1) Building nokogiri using packaged libraries.

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /Users/muescha/.rbenv/versions/1.9.3-p327/bin/ruby extconf.rb 
Building nokogiri using packaged libraries.
-----
libiconv is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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/muescha/.rbenv/versions/1.9.3-p327/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

Gem files will remain installed in /Users/muescha/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /Users/muescha/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.2.1/ext/nokogiri/gem_make.out

An error occurred while installing nokogiri (1.6.2.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.2.1'` succeeds before bundling.

muescha$ bundle --version
Bundler version 1.3.5
muescha$ iconv --version
iconv (GNU libiconv 1.11)
Copyright (C) 2000-2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Bruno Haible.
muescha$ which iconv
/usr/bin/iconv
muescha commented 10 years ago

FYI:

i got it installed with this:

http://stackoverflow.com/questions/5528839/why-does-installing-nokogiri-on-mac-os-fail-with-libiconv-is-missing#comment30773476_6163052

If you're running Mavericks, you may need to install 
Xcode's command line tools: xcode-select --install. 
This fixed the problem for me.

it looks like that the error message is wrong for the libiconv - it better should check before if the xcode command line tools are installed

firedev commented 10 years ago

Nothing I did helped. I have installed all the libraries and supplied every command line argument I have found on StackOverflow and Github:

$ ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install nokogiri -- --with-iconv-dir=/usr/local/opt/libiconv --with-xslt-dir=/usr/local/opt/libxslt
Building native extensions with: '--with-iconv-dir=/usr/local/opt/libiconv --with-xslt-dir=/usr/local/opt/libxslt'
This could take a while...
Building nokogiri using packaged libraries.
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /Users/pain/.rbenv/versions/2.1.1/bin/ruby extconf.rb --with-iconv-dir=/usr/local/opt/libiconv --with-xslt-dir=/usr/local/opt/libxslt
Building nokogiri using packaged libraries.
checking for iconv.h... *** 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/pain/.rbenv/versions/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
/Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:1067:in `block in have_header'
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
    from /Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:1066:in `have_header'
    from extconf.rb:103:in `have_iconv?'
    from extconf.rb:148:in `block (2 levels) in iconv_prefix'
    from extconf.rb:90:in `preserving_globals'
    from extconf.rb:143:in `block in iconv_prefix'
    from extconf.rb:116:in `block in each_iconv_idir'
    from extconf.rb:113:in `each'
    from extconf.rb:113:in `each_iconv_idir'
    from extconf.rb:137:in `iconv_prefix'
    from extconf.rb:424:in `block in <main>'
    from extconf.rb:161:in `block in process_recipe'
    from extconf.rb:154:in `tap'
    from extconf.rb:154:in `process_recipe'
    from extconf.rb:419:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/pain/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /Users/pain/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.2.1/gem_make.out
zenspider commented 10 years ago

@firedev did you see:

/Users/pain/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.

Have you ensured that you have the cmdlline tools installed? As @muescha points out, you might have to run:

xcode-select --install
firedev commented 10 years ago

Sure thing:

$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

Everything works except gem install nokogiri and gem install rmagick.

flavorjones commented 10 years ago

I don't see an mkmf.log in this issue thread. Can anyone provide that? On Jul 3, 2014 5:38 AM, "Nick Ostrovsky" notifications@github.com wrote:

Sure thing:

$ xcode-select --install xcode-select: error: command line tools are already installed, use "Software Update" to install updates

Everything works except gem install nokogiri and gem install rmagick.

— Reply to this email directly or view it on GitHub https://github.com/sparklemotion/nokogiri/issues/1111#issuecomment-47886090 .

firedev commented 10 years ago
"gcc-4.2 -o conftest -I/Users/pain/.rbenv/versions/2.1.1/include/ruby-2.1.0/x86_64-darwin13.0 -I/Users/pain/.rbenv/versions/2.1.1/include/ruby-2.1.0/ruby/backward -I/Users/pain/.rbenv/versions/2.1.1/include/ruby-2.1.0 -I. -I/usr/include -I/Users/pain/.rbenv/versions/2.1.1/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -Wno-error=shorten-64-to-32  -pipe  -g -DXP_UNIX -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c  -L. -L/Users/pain/.rbenv/versions/2.1.1/lib -L/usr/lib -L. -L/Users/pain/.rbenv/versions/2.1.1/lib  -fstack-protector     -lruby-static -framework CoreFoundation  -lpthread -ldl -lobjc  "
couldn't understand kern.osversion `14.0.0'
In file included from /usr/include/stdio.h:65,
                 from /Users/pain/.rbenv/versions/2.1.1/include/ruby-2.1.0/ruby/defines.h:26,
                 from /Users/pain/.rbenv/versions/2.1.1/include/ruby-2.1.0/ruby/ruby.h:29,
                 from /Users/pain/.rbenv/versions/2.1.1/include/ruby-2.1.0/ruby.h:33,
                 from conftest.c:1:
/usr/include/Availability.h:174:44: error: missing binary operator before token "("
/usr/include/Availability.h:184:44: error: missing binary operator before token "("
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */
zenspider commented 10 years ago

On Jul 3, 2014, at 4:52, Nick Ostrovsky notifications@github.com wrote:

"gcc-4.2 -o conftest -I/Users/pain/.rbenv/versions/2.1.1/include/ruby-2.1.0/x86_64-darwin13.0 -

gcc-4.2 is a homebrew recipe. It hasn't been shipped by apple in ages. Can you verify that it is in /usr/local/bin (or wherever your homebrew is) and then unlink it and try again?

firedev commented 10 years ago

I have uninstalled gcc-4.2 but nokogiri tries to use it still:

$ brew uninstall apple-gcc42
Uninstalling /usr/local/Cellar/apple-gcc42/4.2.1-5666.3...

$ which gcc-4.2
gcc-4.2 not found

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

$ cat ~/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.2.1/mkmf.log                                    1 ↵
"gcc-4.2 -o conftest -I/Users/pain/.rbenv/versions/2.1.1/include/ruby-2.1.0/x86_64-darwin13.0 -
...
zenspider commented 10 years ago

Because the ruby you're installing with was compiled with it. Try with your stock ruby or rebuild your rbenv version.

On Jul 3, 2014, at 21:16, Nick Ostrovsky notifications@github.com wrote:

I have uninstalled gcc-4.2 but nokogiri tries to use it still:

$ brew uninstall apple-gcc42 Uninstalling /usr/local/Cellar/apple-gcc42/4.2.1-5666.3...

$ which gcc-4.2 gcc-4.2 not found

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

$ cat ~/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.2.1/mkmf.log 1 ↵ "gcc-4.2 -o conftest -I/Users/pain/.rbenv/versions/2.1.1/include/ruby-2.1.0/x86_64-darwin13.0 - ... — Reply to this email directly or view it on GitHub.

firedev commented 10 years ago

@zenspider Thank you! I was pulling my hair out already.

zenspider commented 10 years ago

On Jul 4, 2014, at 1:11, Nick Ostrovsky notifications@github.com wrote:

@zenspider Thank you! I was pulling my hair out already.

Does that mean it worked for you?

If so, can you write up a summary of what you needed to do/change to get going? That will help me get it into the guide.

firedev commented 10 years ago

Basically something like this:

$ brew uninstall apple-gcc42
$ rbenv uninstall 2.1.1
$ rbenv install 2.1.1

That also fixed an issue with gem rmagick

nlfiedler commented 10 years ago

My setup is like @dmitrytrager and like @firedev I have tried every single solution known to Man. The only work-around I have for now is to install 1.6.1 rather than the latest (1.6.2). The mkmf.log output suggests that the number of arguments to the iconv_open() function is incorrect. See this related issue in another project, https://github.com/rails-sqlserver/tiny_tds/issues/104 , and this rather old but still relevant discussion, https://www.ruby-forum.com/topic/1354865 . Thanks for looking at this.

allaire commented 10 years ago

This worked for me:

You need to uninstall nokogiri (if installed with brew paths or anything like that), install build tools from apple: xcode-select --install and then re-install nokogiri.

zenspider commented 10 years ago

On Jul 15, 2014, at 10:32, Mathieu Allaire notifications@github.com wrote:

This worked for me:

You need to uninstall nokogiri (if installed with brew paths or anything like that), install build tools from apple: xcode-select --install and then re-install nokogiri.

I'll try to get a PR in for the readme today

allaire commented 10 years ago

It would be cool if others could test that it works for them too.

nlfiedler commented 10 years ago

@allaire: I did not have Nokogiri installed and I did try the xcode-select --install solution (as well as try the late October 2013 Xcode command line tools): it did not make any difference. What I have learned is that it looks like mkmf is fragile with respect to certain compilers. Everyone has a different environment and thus different solutions work for them. None of them work for me. If you give me the commands to query my setup, I'll give you the results. I honestly don't know enough about C/C++ programming to know what's going on. As I mentioned before, selecting an earlier version of Nokogiri worked for me, without any special flags: sudo gem install nokogiri -v '1.6.1'

ghost commented 10 years ago

@allaire: I tried for 2 days installing Nokogiri 1.6.3 ! wo any success .. trying each hint found on StackOverflow... even if the CLI is installed , I get the msg : You have to install development tools first...

I checked building native extension with another gem and succeeded to install the latest ffi gem..., so it's not an issue with CLI ... but with Noogiri ...

nlfiedler commented 10 years ago

I have both Mavericks and Lion and have trouble on both. After installing the command line tools via Xcode's preferences dialog, I am still unable to install nokogiri 1.6.3 on Lion. The contents of the mkmf.log file are below:

"gcc-4.2 -o conftest -I/usr/local/include/ruby-2.1.0/x86_64-darwin11.0 -I/usr/local/include/ruby-2.1.0/ruby/backward -I\
/usr/local/include/ruby-2.1.0 -I. -I/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENT\
RANT   -I/usr/local/include -pipe  -Wno-error=unused-command-line-argument-hard-error-in-future -O3 -Wall -Wcast-qual -\
Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c  -L. -L/usr/local/lib -L/usr/lib -L. -L/usr/local/li\
b -fstack-protector     -lruby-static -framework CoreFoundation  -lpthread -lgmp -ldl -lobjc  "
cc1: error: -Werror=unused-command-line-argument-hard-error-in-future: No option -Wunused-command-line-argument-hard-er\
ror-in-future
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */
$ gcc-4.2 --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
flavorjones commented 10 years ago

Hi, there are multiple issues now being reported under this Github Issue.

@erwin you couldn't possibly have been trying for two days, as 1.6.3 was just released yesterday. Please open a new issue with information about your system if you'd like to report an issue.

@nlfiedler The 1.6.3 installation problem related to -Werror=unused-command-line-argument-hard-error-in-future will be fixed in 1.6.3.1 which I'm building right now.

The libiconv issue, which is the original problem reported in this issue, should still be considered open.

JezC commented 10 years ago

I have two Macs. One has the problem of the OP, with nokogiri 1.6.2 and 1.6.3. The other... does not. The difference? The one that works, has had this command applied:

bundle config build.nokogiri --with-iconv-include=/opt/local/include

Because I've built a version of libiconv from source and put it in /opt/local.

If I replace the /opt/local/include with /usr/include, I get the failures of the OP again.

Note that the Mac does have /usr/lib/libiconv.2.dylib and that a "nm" of this library suggest that iconv_open is a recognised symbol. Without digging into the compilation system a little deeper, I don't really know what's going wrong. But I have a workround that works enough for development. I wouldn't be deploying on a Mac, so if it works in dev, with no testing errors trackable to it... it works well enough.

I'm still curious as to why the Apple supplied include file and library aren't usable. That's just my monkey curiousity (en_gb), though. :)

JezC commented 10 years ago

Bah. Answers involving 'bundler' are, of course, only sanely useful for ruby based problems.

Slight further digging suggests that some software doesn't like Apple's libiconv, because it offers iconv_open, not libiconv_open. That seems a pretty odd problem It'd be fairly easy, surely, to write a wrapper function that just calls the Apple functions? Personally I'd rather install a lightweight shroud around a system resource, than have to maintain yet another 3rd party resource.

shepmaster commented 10 years ago

A coworker was also having a problem where the error text suggested it couldn't find iconv, and running xcode-select --install cleared up his issue. Thanks!

JezC commented 10 years ago

Here's a gist of the mkmf.log and some notes on various attempts to use xcode-select: https://gist.github.com/JezC/aee8e41bddac27d78ce7#file-gistfile1-txt

kchasel commented 10 years ago

I'll throw in here that I was having this issue as well on a fairly clean install of Mavericks (10.9.4) and Xcode 5.1.1. I got no errors about missing command line tools, but xcode-select --install did run and resolved this for me as well.

muescha commented 10 years ago

Mhh

1) i still wondering how difficult it would be if i install the current nokogiri on a virtual server?

2) Exists there some rewrite/fork of nokogiri which not need this (hatd to install) libs and run on every system?

flavorjones commented 10 years ago

@muescha - the XCode workaround is only necessary on OSX Mavericks. Do you have virtual servers running Mavericks? If not, can you please explain what you are trying to accomplish, and what the problem you're encountering is?

muescha commented 10 years ago

I have one virtual server (@dreamhost) with an old version of nokogiri and now i fear to upgrade it when it makes this lot of trouble on my local dev osx.

JezC commented 10 years ago

@muescha - the issue appears restricted to OS X. I have several Linux VMs on different distros and it is just fine on those. That's partially bacuse a GNU iconv is included in most distros.

@nike_delassio - I think the issue may be something to do with having brew/macports projects previously installed. I'm planning to re-install a Mac Mini over the next few weeks and see if I can compile on a fresh clean machine. And then add some macports/brew projects to see if that then triggers failure. I'm pretty sure the key issue is that the configuration process decides that it can't use the Apple iconv, because it doesn't supply libiconv_open. And that decision will have been because an include file is supplying a macro that renames the test for iconv_open to be a test for libiconv_open, I think. So my guess is that we include everything we can, check for the system library, find it fails, and go on to look for a brew/macports installation, but not necessarily in the directories that the lib is in (because I have to over-ride the build process). That's what my mkmf.log is suggesting to me, anyway :)

On Mon, Jul 28, 2014 at 9:10 PM, muescha notifications@github.com wrote:

I have one virtual server (@dreamhost https://github.com/dreamhost) with an old version of nokogiri and now i fear to upgrade it when it makes this lot of trouble on my local dev osx.

— Reply to this email directly or view it on GitHub https://github.com/sparklemotion/nokogiri/issues/1111#issuecomment-50392103 .

Jeremy Chatfield - Skype: jezchatfield, Mobile: +44(0)7780 607613

muescha commented 10 years ago

@JezC thx - i think this should better described in the install section. Maybe also some small one line script where i can check the requirements

ghost commented 10 years ago

xcode-select --install worked for a 2013 rMBP updated to Mavericks, using Homebrew 0.9 and rbenv local ruby 2.1.2 installation

JezC commented 10 years ago

I did a fresh install of OS X 10.9.4 (technically, Mountain Lion, then immediately upgraded to Mavericks - just because I had a Mountain Lion USB stick to hand). Installed Xcode 5.1.1, and ran it, accepting license and updating downloads in the Preferences. It has command line tools built in. Tried to build, and it fails saying that "package configuration for libiconv is not found".

Ran 'xcode-select --install' and accepted the pop up window. Retried the installation, and it completes.

Looks to me like part of the problem is installing brew, probably trying to handle the libx* issues, or as in my case, becaue I had other projects that used brew components. That residue of other projects probably then creates include files on the path that override the iconv_open name to libiconv_open - which the system libs can't satisfy. You then end up having to install libiconv as well, just to get the renamed function to be found...

Put more simply, if your system is plain, then 'xcode-select --install' probably works. If you have touched brew (or macports, too, probably), then you may be at risk of inadvertently renaming the needed function call, to something that the install process can't understand and use. You end up installing GNU libiconv to satisfy the need for libiconv_open, instead of using the system iconv.

I'm now planning to taint the Mac Mini I'm using for this, so that I can probe what causes the build to fail when xcode is installed and potentially able to work, such that one needs to install GNU iconv to make nokogiri work. Because that's where I spent a lot of time - struggling with a compiler that worked, and an iconv that should have compiled and wouldn't. My suspicion is that once you use brew or macports, even for another project, you're then committed to eventually installing GNU iconv.

amejiarosario commented 10 years ago

:+1: for xcode-select --install

JeremyEnglert commented 10 years ago

I had a similar experience as @kchasel. No Xcode errors, but running 'xcode-select --install' seemed to fix the issue.

SteveBenner commented 10 years ago

Check it out, and please feel free to contribute--maybe we can boil this down to one script to fix them all!