Install fails showing:
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... no
checking for libiconv_open() in -liconv... no
libiconv is missing.
However, looking at nokogiri's mkmf.log, the following errors are shown:
ld: warning: ignoring file /usr/local/Cellar/libxslt/1.1.28/lib/libxslt.dylib, **file was built for x86_64 which is not the architecture being linked (i386)**: /usr/local/Cellar/libxslt/1.1.28/lib/libxslt.dylib
ld: warning: ignoring file /usr/local/Cellar/libxml2/2.9.1/lib/libxml2.dylib, **file was built for x86_64 which is not the architecture being linked (i386)**: /usr/local/Cellar/libxml2/2.9.1/lib/libxml2.dylib
ld: warning: ignoring file /usr/local/Cellar/libiconv/1.14/lib/libiconv.dylib, **file was built for x86_64 which is not the architecture being linked (i386)**: /usr/local/Cellar/libiconv/1.14/lib/libiconv.dylib
I have xcode and it's command tools installed.
My ~/.bash_profile has 64bit compiling forced by: export ARCHFLAGS="-arch x86_64"
I have libxml2, libxslt, and libiconv installed via Homebrew, and each is linked.
I've tried installing all of these without the ARCHFLAG in .bash_profile.
I've also brew install apple-gcc42 and linked, as per how tos I've found.
I've tried installing nokogiri by passing paths to libxml2, libxslt, and libiconv in /usr/local/Cellar/, but the install still fails, with same errors as above.
I've wasted at least a day on this - just trying to get one Ruby gem installed. I'd really like to get back to actually developing.
Can anyone please help?
Setting NOKOGIRI_USE_SYSTEM_LIBRARIES=1 before actually installing the gem did the trick for me.
Summarising:
If previously installed, uninstall the gem:
$ gem uninstall nokogiri
Use Homebrew to install libxml2, libxslt and libiconv if needed:
$ brew install libxml2 libxslt libiconv
Install the gem specifying the paths to the libraries to be linked against:
$ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"
Check if HomeBrew is installed correctly with the appropriate XCode command line tools.
brew doctor
You can also check via XCode > Preferences
With valid command line tools installed, I was able to resolve the nokogiri error encountered after the OSX Maverick upgrade.
Also found that some of the 'brew' packages were outdated after the OS X Mountain Lion to Maverick upgrade. (e.g. qt, postgresql)
Here's what worked for me:
If you haven't already done so, install the XCode developer tools: $ xcode-select --install
Use homebrew to install (or reinstall) libxml2, libxslt and libiconv: $ brew install libxml2 libxslt libiconv
Install nokogiri: gem install nokogiri -- --with-iconv-dir=/usr/local/opt/libiconv
I found the solution I needed in an unmerged pull request to update the Nokogiri tutorials. I recommend that if someone else encounters this issue and has exhausted the solutions here, check that pull request list to see if someone has submitted an update to the instructions on the Nokogiri tutorials page.
From github page
First, you should:
xcode-select --install
and then re-install nokogiri.
That worked for me while another suggestion didn't. Hope this helps someone else.
Related
Updating RMagick and Imagemagick is a painful expierence. I have updated the Imagemagick version on my mac (MacOS El Capitan Version 10.11.5) with homebrew for one project in Ruby 2.3 to 6.9.5-9
$ convert --version
Version: ImageMagick 6.9.5-9 Q16 x86_64 2016-09-09
Now an older project in Ruby 1.8.7 refuses to work with the error message "this installation of RMagick was configured with ImageMagick 6.8.9 but ImageMagick 6.9.5-9 is in use". Thus I uninstalled "rmagick", but it can not be installed again
$ gem install rmagick -v 2.16.0
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
checking for /usr/local/opt/gcc46/bin/gcc-4.6... yes
checking for Magick-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... no
checking for Ruby version >= 1.8.5... yes
checking for stdint.h... no
checking for sys/types.h... no
checking for wand/MagickWand.h... no
Can't install RMagick 2.16.0. Can't find MagickWand.h.
And if it can not be installed, the whole application can not be started. I tried all the answers from here, and none of them works on MacOS :-( I reinstalled imagemagick and pkg-config with homebrew, and tried various version of RMagick without success. 2.16.0 is the latest version of RMagick currently.
MagicWand seems to be used in ImageMagick version > 6.9, and it can be found on the machine:
find /usr/local -name MagickWand.h
=> /usr/local/Cellar/imagemagick/6.9.5-9_1/include/ImageMagick-6/wand/MagickWand.h
find /usr/local -name MagickWand.pc
=> /usr/local/Cellar/imagemagick/6.9.5-9_1/lib/pkgconfig/MagickCore.pc
It does not work even if I specifiy the these paths during the gem install (same error as above) :-(
C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.9.5-9_1/include/ImageMagick-6 PKG_CONFIG_PATH=/usr/local/lib/pkgconfig gem install rmagick
UPDATE:
The error only occurs for Ruby 1.8.7, it is possible to install RMagick for Ruby 2.0 and Ruby 2.3. Ruby 1.8.7 and ImageMagick 6.9.5 do not seem to be compatible.
Ruby 1.8.7 x
Ruby 2.0.0 ✓
Ruby 2.3.1 ✓
To solve the issue in Mac OSX Sierra, High Sierra, El Capitan, Mojave, Catalina, Big Sur, and Monterey (M1 chip), you can do the following:
brew unlink imagemagick
brew install imagemagick#6 && brew link imagemagick#6 --force
imagemagick#6 is keg-only, so you'll need to force linking.
I had this same issue with ImageMagick 7.0.4-4. The proper fix is to install imagemagick#6. I found https://github.com/Homebrew/homebrew-core/pull/8756 useful if you accidentally deleted your imagemagick#6 or never had it installed in the first place.
macOs Sierra:
brew uninstall imagemagick
brew install imagemagick#6
brew link imagemagick#6 --force
First of all
unlink your installed imagemagick which was not properly installed in latest mac high sierra by using.
brew unlink imagemagick
then install latest imagemagic6 using below command
brew install imagemagick#6 && brew link imagemagick#6 --force
Then install gem rmagick using below command
gem install rmagick
It will work perfectly fine.
yah this one solves my issue:
MacOS X Sierra:
brew uninstall imagemagick
brew install imagemagick#6
brew link imagemagick#6 --force
Many things have changed in ImageMagick 7 like this path: include/.../wand , and wand/MagickWand.h is hardwired in the rmagic gem at the moment. In my case it was not possible to update the gem since the project is rather old. So I ended up installing an older version of ImageMagic.
You can install the latest version from 6.x.x:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/6f014f2b7f1f9e618fd5c0ae9c93befea671f8be/Formula/imagemagick.rb
You can also pin it for later usege:
brew pin imagemagick
Something changed with ImageMagick 7.0.4-4 for me. wand/MagickWand.h couldn't be found any more:
% brew unlink imagemagick && brew link imagemagick
Unlinking /usr/local/Cellar/imagemagick/7.0.4-4... 71 symlinks removed
Linking /usr/local/Cellar/imagemagick/7.0.4-4... 71 symlinks created
% gem install rmagick
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/holger/.rbenv/versions/2.2.2/bin/ruby -r ./siteconf20170116-21103-1aikaka.rb extconf.rb
checking for clang... yes
checking for Magick-config... no
checking for pkg-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... 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.16.0. Can't find MagickWand.h.
I still had ImageMagick 6.9.7-3 on my system and changed back with
% brew switch imagemagick 6.9.7-3
Cleaning /usr/local/Cellar/imagemagick/6.9.6-6
Cleaning /usr/local/Cellar/imagemagick/6.9.7-0
Cleaning /usr/local/Cellar/imagemagick/6.9.7-1
Cleaning /usr/local/Cellar/imagemagick/6.9.7-3
Cleaning /usr/local/Cellar/imagemagick/7.0.4-4
75 links created for /usr/local/Cellar/imagemagick/6.9.7-3
Afterwards I could install rmagick without trouble:
% gem install rmagick
Building native extensions. This could take a while...
Successfully installed rmagick-2.16.0
1 gem installed
RMagick depends on an outdated version of imagemagick, version 6.(see below) Homebrew offers this as a keg-only package, which you can install with:
brew install imagemagick#6
The build output will include a Caveats section (also available from brew info imagemagick#6 if you cleared the output):
==> Caveats
imagemagick#6 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have imagemagick#6 first in your PATH run:
echo 'export PATH="/usr/local/opt/imagemagick#6/bin:$PATH"' >> ~/.zshrc
For compilers to find imagemagick#6 you may need to set:
export LDFLAGS="-L/usr/local/opt/imagemagick#6/lib"
export CPPFLAGS="-I/usr/local/opt/imagemagick#6/include"
For pkg-config to find imagemagick#6 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/imagemagick#6/lib/pkgconfig"
Rather than force-linking, which has the potential to cause problems with other software that does support newer versions of imagemagick, you can use the suggested exports to make the RMagick gem pick up the old version while it builds:
export LDFLAGS="-L/usr/local/opt/imagemagick#6/lib"
export CPPFLAGS="-I/usr/local/opt/imagemagick#6/include"
export PKG_CONFIG_PATH="/usr/local/opt/imagemagick#6/lib/pkgconfig"
gem install rmagick
Go help contribute to the upgrade effort if you know Ruby and C!
Install imagemagick version 6 because version 7 is not compatible:
$ brew install imagemagick#6
Should not link --force the older version because this will change the binaries in your path and the good brew doctor will complain.
Reference the headers and libraries from version 6 that was installed when building the native extension of the gem:
$ PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick#6/6.9.10-14/lib/pkgconfig/ gem install rmagick -v '2.16.0'
Note: Worked for me without indicating the lib and include folder because the pkgconfig is responsible for this.
Note: 6.9.10-14 is the latest version of imagemagick#6, but feel free to change it if you need to use a different version
$ brew remove imagemagick && brew install imagemagick
$ brew uninstall pkg-config && brew install pkg-config
$ brew unlink pkg-config && brew link pkg-config
$ gem install rmagick
I don't have the reputation yet to leave this as a comment improving another answer, but #Evgeniy28's answer worked for me on Sierra only after also installing pkg-config, which doesn't come installed by default on a fresh Sierra machine.
So:
brew install pkg-config
brew uninstall imagemagick
brew install imagemagick#6
brew link imagemagick#6 --force
Success:
$ gem install rmagick
Building native extensions. This could take a while...
Successfully installed rmagick-2.16.0
Parsing documentation for rmagick-2.16.0
Installing ri documentation for rmagick-2.16.0
Done installing documentation for rmagick after 4 seconds
1 gem installed
Please follow below and change some part according to your need.
brew unlink imagemagick
brew install imagemagick#6 && brew link imagemagick#6 --force
export PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick#6/6.9.9-24/lib/pkgconfig
gem install rmagick -v '2.15.4'
With 7.0.7-1 you can create an symbolic link, but it compilation will fail latter.
cd /usr/local/Cellar/imagemagick/7.0.7-1/include/ImageMagick-7
ln -s MagickWand/ wand
ln -s MagickCore/ magick
Here is how I solved (after lots of tries and fail) on macOS High Sierra 10.13.3 with Homebrew:
it seems that RMagick 2.16.0 is not compatible with the newest version of ImageMagick (Version 7): http://wordsandmagic.com/2017/09/01/RMagick-2-16-0-Error-MagickWand
I uninstalled imagemagick: brew uninstall imagemagick
Then I installed Imagemagick with this formula: https://gist.github.com/JagdeepSingh/4b03cbeab16cc0bc729bbc6d275402d3
gem install rmagick
If you have already installed an old version Imagemagick, this should work: https://stackoverflow.com/a/41674363
There's no need to link or unlink anything, following the instructions from the brew install script helps:
brew install imagemagick#6
LDFLAGS="-L/usr/local/opt/imagemagick#6/lib" CPPFLAGS="-I/usr/local/opt/imagemagick#6/include" PKG_CONFIG_PATH="/usr/local/opt/imagemagick#6/lib/pkgconfig" gem install rmagick
Am working on an legacy Ruby on Rails application (Ruby 2.1.x / Rails 3.2.x) for a client and have needed to get it running on MacOS Big Sur.
After rmagick failed wth the following output:
/Users/robbyrussell/.rbenv/versions/2.1.0/bin/ruby extconf.rb
checking for clang... yes
checking for Magick-config... no
checking for pkg-config... yes
checking for outdated ImageMagick version (<= 6.4.9)... no
checking for presence of MagickWand API (ImageMagick version >= 6.9.0)... 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.16.0. 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.
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/robbyrussell/.rbenv/versions/2.1.0/bin/ruby
extconf failed, exit code 1
Gem files will remain installed in /Users/robbyrussell/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rmagick-2.16.0 for inspection.
Results logged to /Users/robbyrussell/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-20/2.1.0-static/rmagick-2.16.0/gem_make.out
My next step to solve this was to instruct Bundler to pass some flags to the compiler:
bundle config build.rmagick -- --with-cflags=-Wno-implicit-function-declaration
via Homebrew, I ran the following:
% brew install imagemagick#6
Then following the guidance that is output, I ran:
% export PKG_CONFIG_PATH="/usr/local/opt/imagemagick#6/lib/pkgconfig"
% bundle install
.....
Fetching rmagick 2.16.0
Installing rmagick 2.16.0 with native extensions
Voila, I'm now able to run this application locally.
Got same error for alpine 3.9 image build. It comes with ImageMagick 7.0.8.38-r0
To fix that you either use alpine 3.5 with ImageMagick 6.9.6.8-r1:
FROM alpine:3.5
Or install ImageMagick 6.9.6.8-r1 with package repository for 3.5:
RUN apk add imagemagick-dev=6.9.6.8-r1 --repository http://dl-3.alpinelinux.org/alpine/v3.5/main/
There is an open issue in rmagick repo regarding failed builds for ImageMagick 7.0.x. so hopefully it will be fixed soon.
Something was severely wrong on my system, so badly that it was completely f*d up, but I was finally to able to install RMagick for Ruby 1.8.7 again after I installed
an older version of ImageMagick with Homebrew
a new Ruby version of 1.8.7
a new version of GCC
The installation of a new Ruby version with RVM rvm install 1.8.7 also installed a new GCC compiler: it removed an older GCC version 4.6 and installed GCC version 4.9. Apparently GCC was not able to find the right headers despite pkg-config.
First, you don't need to uninstall imagemagick if it has a 6.x installed, like shown below. You can see the current "main" is 7.0.7-8 but 6.9.1-10 is still there.
$ brew info imagemagick
imagemagick: stable 7.0.7-8 (bottled), HEAD
Tools and libraries to manipulate images in many formats
https://www.imagemagick.org/
/usr/local/Cellar/imagemagick/6.9.1-10 (1,450 files, 17.5MB)
Poured from bottle on 2015-07-26 at 09:10:58
/usr/local/Cellar/imagemagick/7.0.6-9 (1,522 files, 22.8MB)
Poured from bottle on 2017-08-21 at 14:44:16
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula
If you don't have an old 6.x version, then install imagemagick#6.
Second, do not force link imagemagick, especially not 6. EDIT: See ¹
You need to set PKG_CONFIG_PATH in addition to the --with-opt-* flags.
This works for me on High Sierra with aforementioned brew setup on Ruby 1.9.3-p551:
PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.9.1-10/lib/pkgconfig \
gem install rmagick -v '2.16.0' -- \
--with-opt-lib=/usr/local/Cellar/imagemagick/6.9.1-10/lib/ \
--with-opt-include=/usr/local/Cellar/imagemagick/6.9.1-10/include/ImageMagick-6/
Building ri docs fails, but those are inconsequential.
¹: Building works, the dylib path RMagick is searching is wrong though. Raised Issue #278 to clarify if this can be fixed. Otherwise manual symlinking of libMagickWand etc is necessary. Might still be safer to manually link the specific libraries than a brew link --force though.
I fully explain the installation process in ImageMagick install in centos .
anyway ...
after install Install Imagick & ImageMagick-devel & ImageMagick PHP library like below:
# yum install ImageMagick
# yum install ImageMagick-devel
# pecl install Imagick
go to /usr/include
cd /usr/include
Important: copy ImageMagick folder from "/usr/include" to "/usr/local/include" for ImageMagick find "MagickWand.h"
I tested this change on imagick-3.4.3(ImageMagick-7) and centos 6.5 and php56 and works perfectly ...
If you have already installed "ImageMagick" several times, first remove all of them and find "ImageMagick" & "imagick" folders and clean all of them and continue the installation process with this change.
Use the following command to find a file or folder:
find / -name 'ImageMagick*'
find / -name 'imagick*'
and continue your installation
before below lines don't forget:
go to "php.ini" find "disable_functions" and clean "proc_open,popen,proc_close" becuase make imagick needs these functions,
after complete installation you can add this functions to your "disable_functions" on "php.ini" file.
# phpize
# ./configure --with-php-config=/usr/local/php56/bin/php-config
...
Good luck...
For Ubuntu version > 12 and not using homebrew,
wget http://www.imagemagick.org/download/<required_imagemagick_version>
tar -xvf <path_to_your_downloaded_file>.tar.gz
If you are getting '7z' files instead of 'tar.gz' files in the wget link, then
7z x <path_to_your_downloaded_file>.7z
cd <path_to_your_downloaded_file>/
make
./configure
sudo make install
sudo ldconfig /usr/local/lib
Then you can resume your bundler for RMagick.
Running 'compile' for libxslt 1.1.28... OK
Running 'install' for libxslt 1.1.28... OK
Activating libxslt 1.1.28 (from /Users/Kartik/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.4.1/ports/x86_64-apple-darwin14.0.0/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.
i fiddled around with this for quite a while and the following worked for me..
1) install libxml2 with homebrew
brew install libxml2
2) install the gem via
sudo env ARCHFLAGS="-arch x86_64" gem install nokogiri:1.6.4.1 -- --use-system-libraries --with-xml=/usr/local/Cellar/libxml2/
For any who are still getting "libxml2 version 2.6.21 or later is required!" message, removing --use-system-libraries from hlv's step 2 above, worked for me.
sudo env ARCHFLAGS="-arch x86_64" gem install nokogiri:1.6.4.1 -- --with-xml=/usr/local/Cellar/libxml2/2.9.2/
I finally ended up with this version independent line:
sudo env ARCHFLAGS="-arch x86_64" gem install nokogiri -n /usr/local/bin -- --with-xml=/usr/local/Cellar/libxml2/
This worked for me (assuming Xcode is installed):
gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2 --use-system-libraries
Inspired by https://stackoverflow.com/a/28767045/1884907 (credits to lx00st)
(For MacOX 10.12.x) Perhaps you want to brew install libxml2 and also try linking into /usr/local/ first: brew link --force libxml2, then try that gem install nokogiri -- --use-system-libraries.
Using ports:
gem install nokogiri -- --use-system-libraries --with-xml=/opt/local/lib/libxml2.a
My solution, using ports:
sudo ARCHFLAGS='-arch x86_64' gem install nokogiri -- --use-system-libraries
By default, it will compile for x86_64 and i386, architecture for i386 should disabled, because the dependencies libraries in port only provide x86_64 version by default.
This is a bit of a rehash of all the other answers, but this worked for me:
gem install nokogiri -v '1.6.6.2' -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.16 --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2 --use-system-libraries
I'm installing the Ruby Nokogiri gem and finding the error below.
How to diagnose this and solve it?
# gem install nokogiri
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
...
/opt/ruby/1.9.3-p194/bin/ruby extconf.rb
checking for libxml/parser.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.
...
/opt/ruby/1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in `try_do':
The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /opt/ruby/1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
...
To diagnose and solve, here's what worked for me.
To find out what failed, go to your ruby gems directory.
For example:
$ cd <MY RUBY DIRECTORY>/lib/ruby/gems/2.0.0/gems
If you don't know your gem directory, try this:
$ echo $GEM_HOME
/opt/gems/2.0.0
$ cd /opt/gems/2.0.0/gems
What version of nokogiri am I installing?
$ ls -ladg nokogiri-*
nokogiri-1.5.5
Go to the installer directory:
$ cd nokogiri-1.5.5/ext/nokogiri
Try installing manually:
$ ruby extconf.rb
Result:
checking for libxml/parser.h... *** extconf.rb failed ***
...
I'm using Ubuntu so I search for any similar packages:
$ aptitude search libxml
Results:
p libxml2 - GNOME XML library
p libxml2-dev - Development files for the GNOME XML library
...
I believe that libxml2 will work fine.
$ apt-get install libxml2
Ruby native gems often need the *-dev packages for headers so install them:
$ apt-get install libxml2-dev
Now do I have the parser file?
$ find / | grep libxml/parser.h
Yes, the result shows the parser:
/usr/include/libxml2/libxml/parser.h
Now try installing again, this time providing the libxml2 path:
$ gem install nokogiri -- --with-xml2-dir=/usr/include/libxml2
It still fails, so read the mkmf error log:
$ more mkmf.log
The error log shows what failed and has these lines that look promising:
package configuration for libxslt is not found
Is there a package for it?
$ aptitude search libxslt
Results:
v libxslt-dev
i libxslt-ruby
...
Install the dev package:
$ apt-get install libxslt-dev
Now try installing again, and also put xslt on the path:
$ gem install nokogiri -- \
--with-xml2-dir=/usr/include/libxml2 \
--with-xslt-dir=/usr/include/libxslt
Success!
Installing Nokogiri Website
'Installing Nokogiri' is a website dedicated to installing Nokogiri on the major platforms - Here is an excerpt about Installing Nokogiri on Ubuntu:
Because Nokogiri needs to be compiled and dynamically linked against
both libxml2 and libxslt, it has gained a reputation for being
complicated to install.
As of Nokogiri 1.6, libxml2 and libxslt source code is bundled with
Nokogiri, and compiled at gem-install-time. The instructions in this
document should work for all versions 1.6.4 and later.
Ubuntu / Debian
Installation should Just Work™ on Ubuntu and Debian using Nokogiri’s
vendored libxml2 and libxslt:
gem install nokogiri
[...]
Using Your System Libraries
If, instead of Nokogiri’s vendored libraries, you’d like to use your
system’s libxml2, libxslt and related libraries, please first
understand that you may be asking Nokogiri to work with an unsupported
version of libxml2.
sudo apt-get install pkg-config
gem install nokogiri -- --use-system-libraries
FYI - I am using Nokogiri 1.6.6.2 and it didn't 'just work'. I got it going with the --use-system-libraries.
Mac OS X
The website's advice also covers OS X - this worked for me:
gem update --system
xcode-select --install
gem install nokogiri
Conclusion
If you have a Nokogiri problem on any platform you should check out the website.
On CentOS here is what I needed to do:
gem update --system
yum install libxml2-devel libxslt-devel ruby-devel
gem install nokogiri -- --use-system-libraries
Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers.
You are probably missing zlib headers which are required for -lz flag in order to compile the sources correctly. Install on Linux by:
sudo apt-get install libz-dev
For missing libiconv, try installing libiconv-hook-dev package which has header files of libiconv-hook, e.g.
sudo apt-get install libiconv-hook1 libiconv-hook-dev
On OS X, try installing development tools via: xcode-select --install.
If there is still problem, check mkmf.log file for more specific details about your error.
On Ubuntu, try the following dependency fix combo:
sudo apt-get install gcc ruby-dev libxslt-dev libxml2-dev zlib1g-dev
The 'could not create Makefile' error you're seeing could also be because you haven't agreed to the Xcode license (you have to agree to it after each time you update Xcode). Running sudo xcodebuild -license accept should eliminate this error for you and allow you to then run gem install nokogiri successfully.
I bought a new Mac this week and have had big problems getting this gem installed. It was never a problem on my old Mac but seems to be particularly difficult on this one.
I have installed libvirt via Homebrew, Xcode4.4 (with command line tools) and gcc4.2. I have symlinked to make gcc4.2 the default compiler.
gem install ruby-libvirt -v '0.4.0' fails because it cannot find the headers
If I pass in the paths to the headers and libraries, like so:
ruby-libvirt -v '0.4.0' -V -- --with-libvirt-include=/usr/local/Cellar/libvirt/0.9.11.3/include/ --with-libvirt-lib=/usr/local/Cellar/libvirt/0.9.11.3/lib/
, it compiles just fine but fails when linking with the following errors:
linking shared-object _libvirt.bundle
ld: library not found for -lruby.1.9.1
collect2: ld returned 1 exit status
make: *** [_libvirt.bundle] Error 1
I have installed Ruby 1.9.3 via RVM and haven't had any troubles installing other native extensions, so I cannot see why it fails to find the ruby libraries in this case.
Does anyone have any ideas? Help would be much appreciated.
I built ruby-libvirt-0.4.0/ext/libvirt by proving external libvirt installed using brew.
Here is what I did to successfully install libvirt.
brew install libvirt
ruby extconf.rb --with-libvirt-include=/usr/local/include/libvirt --with-libvirt-lib=/usr/local/lib/libvirt
gem install ruby-libvirt -v '0.4.0' -V -- --with-libvirt-include=/usr/local/Cellar/libvirt/1.1.4/include/libvirt --with-libvirt-lib=/usr/local/Cellar/libvirt/1.1.4/lib
Hope this helps.
To install the gem you need to install the libvirt libraries. Using 'Homebrew' (a package manager for mac) :
brew install libvirt
bundle install
The exact error you got might have been:
An error occurred while installing ruby-libvirt (0.4.0)
I have finally solved this. It turns out that the command line tools were not properly installed. The following line needs to be added to your .zshrc file (or whatever applies to your choice of shell):
export PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:$PATH
You need only to install libvirt, before the bundle install.
brew install libvirt
Got the DevKit installed and re-ran the ffi install….got this as an output:
C:\Documents and Settings\******>gem install ffi
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing ffi:
ERROR: Failed to build gem native extension.
C:/Ruby192/bin/ruby.exe extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include... no
checking for rb_thread_blocking_region()... yes
checking for ruby_thread_has_gvl_p()... yes
checking for ruby_native_thread_p()... yes
checking for rb_thread_call_with_gvl()... yes
creating extconf.h
creating Makefile
make
C:/Ruby192/bin/ruby -e "puts 'EXPORTS', 'Init_ffi_c'" > ffi_c-i386-mingw32.def
gcc -I. -IC:/Ruby192/include/ruby-1.9.1/i386-mingw32 -I/C/Ruby192/include/ruby-1
.9.1/ruby/backward -I/C/Ruby192/include/ruby-1.9.1 -I. -DRUBY_EXTCONF_H=\"extcon
f.h\" -O3 -g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -
Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-declaration-a
fter-statement -o AbstractMemory.o -c AbstractMemory.c
In file included from AbstractMemory.c:28:0:
compat.h:65:20: warning: extra tokens at end of #ifndef directive
compat.h:69:24: warning: extra tokens at end of #ifndef directive
In file included from AbstractMemory.h:29:0,
from AbstractMemory.c:29:
Types.h:68:17: fatal error: ffi.h: No such file or directory
compilation terminated.
make: *** [AbstractMemory.o] Error 1
Gem files will remain installed in C:/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.1
0 for inspection.
Results logged to C:/Ruby192/lib/ruby/gems/1.9.1/gems/ffi-1.0.10/ext/ffi_c/gem_m
ake.out
_________________________________________________________________________________
Not sure how to deal with this issue. Kindly help.
The gem install ffi fails due to the gem trying to build a bundled copy of libffi, which does not work due to assumptions that /usr/bin/env exists and too old libffi copy.
However, you can build the ffi gem against the system libffi - install the packages:
apt install clang make ruby-dev libffi-dev
After that the ffi gem should build:
gem install ffi
Version 1.0.10 has issues compiling on windows.
You can use the 1.0.9
gem install ffi --version='1.0.9'
sudo apt-get install libffi-dev
This worked for me
For me the fix was running in this order. I'm not sure what all was relevant, but it worked:
gem install ffi --version '1.0.9'
The above failed, but then I could successfully run:
gem install bundler
...and subsequently:
gem install ffi
...which got the latest version (1.6.0 at the time of writing this) and installed it successfully.
Note that installing version 1.0.9 isn't going to be enough if your bundler keeps trying to go out and grab the latest version. In your gemfile you'll also want to put:
gem 'ffi', '1.0.9'
This should satisfy the dependency for whatever gem is asking for it and let you get up and running.
when the above steps are followed, it might results the following message.
$ bundle install
Fetching source index for https://rubygems.org/
You have requested:
ffi = 1.0.9
The bundle currently has ffi locked at 1.0.11.
Try running `bundle update ffi`
In that case, you can run the 'bundle update ffi' command and the error will be solved.
Installing the 'osx-gcc-installer' worked for me: (osx 10.8)
https://github.com/kennethreitz/osx-gcc-installer/downloads
Helped me:
sudo apt install build-essential
Debian 9
Ruby 2.3.3
you need this,
apt-get install ruby2.2-dev
Copied from another post:
As stated in Issue with installing ImageMagick and rmagick on Mountain Lion, ffi appears to be configured to look for 'gcc-4.2', so once I updated my Apple command line tools (which I may or may not have needed to do), I created a symbolic link to make the ffi install configuration happy:
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
For me, this usually works
gem install ffi -- --disable-system-libffi
On MacOS (Catalina), running brew install libtool first solved the problem for me.
This worked for me
gem install ffi -- --disable-system-libffi
on Ubuntu 20.04 (WSL)
Put DevKit in front of your PATH, and install again from Windows command prompt.
I got the same problem. In my case, I have not install the DevKit, which can be found: http://rubyinstaller.org/downloads/. After installing DevKit, just follow the instruction https://github.com/oneclick/rubyinstaller/wiki/development-kit and finally it's up and running.
I had to install automake to get it working. Worked on both mac OSX as well as Ubuntu (CI machine).
Run this: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then: brew install cocoapods