Not able to install Nokogiri 1.6.0 on Mac (Mountain Lion)? - ruby

I am not able to install Nokogiri on my Mac running Mountain Lion.
I tried to install it using command:
gem install nokogiri -v '1.6.0'
I get this output:
Building native extensions. This could take a while...
/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/1.9.1/rubygems/ext/builder.rb:48: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/usr/local/Cellar/ruby193/1.9.3-p448/bin/ruby extconf.rb
/usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/mini_portile-0.5.1/lib/mini_portile.rb:215: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin12.5.0/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 /usr/local/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin12.5.0/libxml2/2.8.0)...
Extracting libxslt-1.1.26.tar.gz into tmp/x86_64-apple-darwin12.5.0/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 /usr/local/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin12.5.0/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... no
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... yes
checking for exsltFuncRegister() in -lexslt... yes
checking for xmlHasFeature()... yes
checking for xmlFirstElementChild()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetValidStructuredErrors()... yes
checking for xmlSchemaSetValidStructuredErrors()... yes
checking for xmlSchemaSetParserStructuredErrors()... yes
creating Makefile
make
compiling html_document.c
gcc-4.7: error: unrecognized command line option '-Wshorten-64-to-32'
make: *** [html_document.o] Error 1
Gem files will remain installed in /usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.0 for inspection.
Results logged to /usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.0/ext/nokogiri/gem_make.out
Can anyone please help me?

I was getting the same error with 1.6.1. I solved this on OS X Mavericks by switching to llvm-gcc.
CC=llvm-gcc gem install nokogiri -v '1.6.1'

Related

Cannot install jekyll on Ubuntu 17.10

Trying to install Jekyll but keep getting this error message:
current directory: /var/lib/gems/2.3.0/gems/ffi-1.9.21/ext/ffi_c
/usr/bin/ruby2.3 -r ./siteconf20180219-16974-6pgqng.rb extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for shlwapi.h... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
creating extconf.h
creating Makefile
current directory: /var/lib/gems/2.3.0/gems/ffi-1.9.21/ext/ffi_c
make "DESTDIR=" clean
current directory: /var/lib/gems/2.3.0/gems/ffi-1.9.21/ext/ffi_c
make "DESTDIR="
Running autoreconf for libffi
/var/lib/gems/2.3.0/gems/ffi-1.9.21/ext/ffi_c/libffi/autogen.sh: 2: exec: autoreconf: not found
libffi.mk:6: recipe for target '"/var/lib/gems/2.3.0/gems/ffi- 1.9.21/ext/ffi_c/libffi-x86_64-linux-gnu"/.libs/libffi_convenience.a' failed
make: *** ["/var/lib/gems/2.3.0/gems/ffi-1.9.21/ext/ffi_c/libffi-x86_64-linux-gnu"/.libs/libffi_convenience.a] Error 127
make failed, exit code 2
I have installed the following but perhaps not in this order
make
build-essential
ruby
ruby-dev
gcc
Any ideas?
Solved!
had to run the command:
sudo apt-get install autoconf libtool

Can't install RMagick 2.15.4. Can't find MagickWand.h

While I'm trying to install rmagic, it shows following error
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/***/.rvm/rubies/ruby-2.2.3/bin/ruby -r ./siteconf20170814-
44982-1i5w4mc.rb extconf.rb
checking for gcc... yes
checking for Magick-config... no
checking for pkg-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no
Can't install RMagick 2.15.4. Can't find MagickWand.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.
I'm using MacOS sierra, ruby version 2.2.3
I had this issue a while back. You need to install imagemagick. Per the github repo for the rmagic gem
Pre-reqs:
ImageMagick Version 6.4.9 or later. You can get ImageMagick from www.imagemagick.org.
I believe you can also install it with brew
$ brew install imagemagick#6
$ brew link imagemagick#6 --force
$ gem install rmagick
brew unlink pkgconfig
bundle install
brew link pkgconfig
did the trick for me

Gem install Fail on Shared VirtualBox Folder

There's a Windows Host and an Ubuntu guest using VirtualBox.
We can gem install just fine for individual gems on Ubuntu. When running
bundle install --path vendor
for an app that is on a shared folder in Ubuntu it fails with.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-2.1.1/bin/ruby extconf.rb
/var/www/chef-playground/vendor/ruby/2.1.0/gems/mini_portile-0.5.2/lib/mini_portile.rb:226: warning: Insecure world writable dir /opt/chef/embedded/bin in PATH, mode 040777
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-linux-gnu/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 /var/www/chef-playground/vendor/ruby/2.1.0/gems/nokogiri-1.6.1/ports/x86_64-linux-gnu/libxml2/2.8.0)...
Extracting libxslt-1.1.26.tar.gz into tmp/x86_64-linux-gnu/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 /var/www/chef-playground/vendor/ruby/2.1.0/gems/nokogiri-1.6.1/ports/x86_64-linux-gnu/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... yes
checking for xsltParseStylesheetDoc() in -lxslt... yes
checking for exsltFuncRegister() in -lexslt... yes
checking for xmlHasFeature()... yes
checking for xmlFirstElementChild()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetValidStructuredErrors()... yes
checking for xmlSchemaSetValidStructuredErrors()... yes
checking for xmlSchemaSetParserStructuredErrors()... yes
creating Makefile
Text file busy # unlink_internal - ./siteconf20140313-27134-167s4eq.rb
Gem files will remain installed in /var/www/chef-playground/vendor/ruby/2.1.0/gems/nokogiri-1.6.1 for inspection.
Results logged to /var/www/chef-playground/vendor/ruby/2.1.0/extensions/x86_64-linux/2.1.0/nokogiri-1.6.1/gem_make.out
An error occurred while installing nokogiri (1.6.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.1'` succeeds before bundling
The last line of your stack trace has the explanation.
An error occurred while installing nokogiri (1.6.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.1'` succeeds before bundling
I ran into the same error while using it on Fedora 20. There is a good explanation of how to overcome it at the nokogiri site.
I ran the following 2 commands and then the bundle install worked:
sudo yum install -y rubygem-nokogiri
sudo yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel
It might be because of this:
Text file busy # unlink_internal - ./siteconf20140313-27134-167s4eq.rb
This is apparently an existing problem with regards to sharedfolders, Virtualbox and Windows hosts. It seems they have been blaming Window's aggressive file handling.
https://github.com/mitchellh/vagrant/issues/2282
Ansible text file busy error
https://unix.stackexchange.com/questions/52951/gedit-wont-save-a-file-on-a-virtualbox-share-text-file-busy
You can try a workaround by installing the gems somewhere on guest machine instead of inside your sharedfolder i.e. install your gems in your home directory: bundle install --path ~/vendor. You might have to reconfigure your .bundle/config to make sure you're pointing at the correct directory.

Install problems: Nokogiri on Mac OSx Mountain Lion

For some reason I cannot install Nokogiri on my MacBook for traveling.
This is short output from gem install nokogiri:
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, I used MacPorts and it says that it's already installed:
port installed | grep lib
libxml #1.8.17_0 (active)
libxml2 #2.9.1_0 (active)
Is it getting confused because both libxml and libxml2 are installed? (Probably not.) Or is there something else going on?
I've followed the installation instructions for Nokigiri installation and that doesn't help.
Finally, I uninstalled ports libxml and libxml2 and now it fails attempting to use libiconv, having gotten past the previous XML issue it seems.
try it
sudo port upgrade outdated

Issue installing the Nokogiri gem in Mac OS X 10.5.8

I'm trying to install the Nokogiri gem under an RVM managed Ruby 1.8.7 installation in OS X Leopard (10.5.8).
I'm getting the following error:
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/user/.rvm/rubies/ruby-1.8.7-p352/bin/ruby extconf.rb
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... no
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... yes
checking for exsltFuncRegister() in -lexslt... yes
checking for xmlHasFeature()... no
-----
The function 'xmlHasFeature' is missing from your installation of libxml2. Likely this means that your installed version of libxml2 is old enough that nokogiri will not work well. To get around this problem, please upgrade your installation of libxml2.
Please visit http://nokogiri.org/tutorials/installing_nokogiri.html for more help!
*** extconf.rb failed ***
I have the latest libxml2 installed via homebrew (brew install libxml2), so I don't know what else to try.
Update:
I tried the instructions from the Nokogiri website and I can't get the Nokogiri gem installation to recognize libxml2.
Per the instructions
I installed and linked libxml2 and libxslt via homebrew:
brew install libxml2 libxslt
brew link libxml2 libxslt
gem install nokogiri
The error message has changed, but the Nokogiri installation complains that libxml2 is missing:
...
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... no
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... no
-----
libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies
The installed libxml2 version is 2.7.8.
Update update:
I tried installing the iconv library from homebrew to see if I could solve the error checking for iconv_open() in iconv.h... no, so I ran the commands:
brew install libiconv
brew link libiconv
And after finishing the installation, I tried to install the nokogiri gem again, to get this error message, where the installer now complains that libiconv is missing
hecking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
-----
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
I'm clueless.
Per the directions at: http://nokogiri.org/tutorials/installing_nokogiri.html you needed to use:
brew install libxml2 libxslt
brew link libxml2 libxslt
then
gem install nokogiri
Did you use those or only brew install libxml2?
Make sure there is no Nokogiri version available:
use gem uninstall nokogiri
First install the command-line tool for Xcode. Refer to "How to use/install gcc on Mac OS X 10.8 / Xcode 4.4".
Then run the following commands:
brew install libxml2
gem install nokogiri
Now it works well, I tried it.
brew install libxml2 libxslt
gem install nokogiri -- \
--with-xml2-lib=/usr/local/Cellar/libxml2/2.7.x/lib \
--with-xslt-dir=/usr/local/Cellar/libxslt/1.1.xx \
--with-iconv-lib=/usr/lib \
--with-iconv-include=/usr/local/include

Resources