Bundle update fails on ffi - ruby-on-rails

I'm attempting to do a bundle update on my rails application but I get the following error:
Installing ffi (1.0.11) with native extensions Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/bundler/issues so that we can fix it. Thanks!
/Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:552:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
checking for ffi.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
--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/Kyle/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
--with-ffi_c-dir
--without-ffi_c-dir
--with-ffi_c-include
--without-ffi_c-include=${ffi_c-dir}/include
--with-ffi_c-lib
--without-ffi_c-lib=${ffi_c-dir}/lib
--with-libffi-config
--without-libffi-config
--with-pkg-config
--without-pkg-config
/Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/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 /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:931:in `block in have_header'
from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:930:in `have_header'
from extconf.rb:9:in `<main>'
Gem files will remain installed in /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/ffi-1.0.11 for inspection.
Results logged to /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/ffi-1.0.11/ext/ffi_c/gem_make.out
from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:530:in `block in build_extensions'
from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:505:in `each'
from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:505:in `build_extensions'
from /Users/Kyle/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:180:in `install'
from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/source.rb:90:in `block in install'
from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/rubygems_integration.rb:82:in `preserve_paths'
from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/source.rb:89:in `install'
from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:73:in `block in install_gem_from_spec'
from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/rubygems_integration.rb:97:in `with_build_args'
from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:72:in `install_gem_from_spec'
from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:56:in `block in run'
from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:55:in `run'
from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:12:in `install'
from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/cli.rb:271:in `update'
from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor/task.rb:22:in `run'
from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor.rb:263:in `dispatch'
from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor/base.rb:386:in `start'
from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/bin/bundle:13:in `<top (required)>'
from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/bin/bundle:19:in `load'
from /Users/Kyle/.rvm/gems/ruby-1.9.3-p125/bin/bundle:19:in `<main>'
Any ideas?

I ran into a problem similar to this yesterday.
I was able to resolve it using these steps:
https://github.com/carlhuda/bundler/blob/1-0-stable/ISSUES.md
Essentially, there was a problem with my bundle and clearing things out and rebuilding things from scratch resolved it.
The steps are repeated here:
# remove user-specific gems and git repos
rm -rf ~/.bundle/ ~/.gem/
# remove system-wide git repos and git checkouts
rm -rf $GEM_HOME/bundler/ $GEM_HOME/cache/bundler/
# remove project-specific settings and git repos
rm -rf .bundle/
# remove project-specific cached .gem files
rm -rf vendor/cache/
# remove the saved resolve of the Gemfile
rm -rf Gemfile.lock
# try to install one more time
bundle install
Although, given the message in the output text:
You have to install development tools first.
That makes me think you just may not have installed the Apple Xcode Developer Tools. Have you checked that? (I believe they're available in the Mac App Store.)

For Xcode 5 and later:
$ xcode-select --install
to install the Command Line Tools.

Once installed gcc-4.2 from brew, you need to create symlink of it:
ln -s /usr/bin/gcc /usr/bin/gcc-4.2

For me I just didn't have gcc installed, solve in Ubuntu by:
sudo apt install build-essential

Just in case try to run
sudo /usr/bin/gcc
You'll probably see license agreement, so scroll thgough it, type "agree" and try to install gem again.

Please note:
If you have recently updated Xcode, you may just need to open Xcode and accept the latest agreement.
I had the same issue and had recently installed an update to Xcode (v6.1) and solved it with these steps:
open Xcode
accept new agreement
rerun bundle update

Installing "Command Line Tools" via Xcode did the trick.
If you have Xcode 4.5 open Preferences > Downloads > Select Components tab and click Install next to Command Line Tools.
Although I installed from Xcode, you can also download the package without it from Apple's Developer Downloads and searching for "Command Line Tools".

I had to accept the Xcode User licence:
Running sudo xcrun cc should bring up the cli version of the Xcode
license agreement. Another option is to open Xcode.app and agree in
the GUI.
Possibly caused by updating OSX.
http://blog.tomhennigan.co.uk/post/62238548037/agreeing-to-the-xcode-license-from-the-command

Mac OSx 10.10.2 yosemite
CC=/usr/bin/i686-apple-darwin11-llvm-gcc-4.2 gem install ffi
and thats it -check that you have 4.2 compiler in /usr/bin that you can hook into
ls /usr/bin|grep gcc|grep 4.2
You do not have to wipe out all of your local gems or override symlinks to do this - its a waste of time and will likely create more problems then it solves.
please note, your bin path may be different if you needed to install via brew
brew install apple-gcc42

Also method:
export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
bundle update
ffi.h is to be found in ${SDKROOT}/usr/include/ffi/ffi.h.

Ubuntu Trusty LTS 14.04
Needed to switch from ruby 2.2.1 to 2.3.0 to support newer gem versions in Rails app.
Solution:
rvm get stable
rvm remove 2.3.0
rvm install 2.3.0
bundle install

Related

rails 5.0.0 when installing "nio4r" : Failed to build gem native extension

Here is the logs: http://pastebin.com/CAgur9xd
Installing nio4r 1.2.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
C:/RailsInstaller/Ruby2.2.0/bin/ruby.exe -r ./siteconf20160720-8272-c88sgk.rb extconf.rb --with-cflags=-std=c99
checking for unistd.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=C:/RailsInstaller/Ruby2.2.0/bin/$(RUBY_BASE_NAME)
C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:587:in `try_cpp'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:1060:in `block in have_header'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:911:in `block in checking_for'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:351:in `block (2 levels) in postpone'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:321:in `open'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:351:in `block in postpone'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:321:in `open'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:347:in `postpone'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:910:in `checking_for'
from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/mkmf.rb:1059:in `have_header'
from extconf.rb:3:in `<main>'
extconf failed, exit code 1
when installing bundle it returns(starts at line 117 in the logs ):
Installing nio4r 1.2.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
So the bundle can't be installed. It returns at the end :
An error occurred while installing nio4r (1.2.1), and Bundler cannot continue.
Make sure that `gem install nio4r -v '1.2.1'` succeeds before bundling.
Note :I have tried the solutions in other questions, but it is still the same.
If it is possible to install "nio4r" manually please tell me how .
I am facing the same issue while I was trying to upgrade my Rails to V5.0.0, I follow this instruction and it works perfectly. Read the section "Install the Ruby DevKit" here >> http://jekyll-windows.juthilo.com/1-ruby-and-devkit/
Solution for Fedora 64bit
sudo dnf install redhat-rpm-config
I had a similar problem and running this command solved my issue.
bundle config build.nio4r --with-cflags="-std=c99"
Now you can successfully run bundle install afterwards.
I came across this problem as i was setting up rails too. (looking for an alternative to php).
I realized that i had installed x86 ruby with x64 Devkit, so i first downloaded x64 ruby which i installed and uninstalled the x86 version. I made sure my path variables were well set.
Then i installed devkit using the instructions on this page http://rubyonwindowsguides.github.io/book/ch02-04.html
Finally i installed rails and it worked fine without the errors this time
Hope this helps
My son fixed this problem for me. The problem was that I installed first, Ruby and then the Rails installer. So I had to uninstall Ruby and reinstall with the Rails installer only.
Had this same issue on Ubuntu 16.04.
What I did to fix this :
Remove Gemfile.lock : sudo rm Gemfile.lock
Installed Ruby-Dev:
sudo apt-add-repository ppa:brightbox/ruby-ng
sudo apt-get update
sudo apt-get install ruby2.4-dev
and the important step : REBOOT!
this may be related: GCC compilation error when installing Nokogiri
I found a error. i had a 2 gcc versions installed on my system and I just run brew unlink gcc and that solved the problem.
this was my case too. benw unlink gcc worked
Remove the Gemfile.lock and run bundle install command
To quote from your log output:
The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
On windows, you need to install the DevKit in order to be able to compile gems.
If you use Windows and installed ruby with RubyInstaller with version more or equal to 2.4, than you should not install DevKit from RubyInstaller website and only use 'msys64' which is installed after Ruby with RubyInstaller (make sure you type number 3 to install both msys and mingw). Delete devkit directory and its path from PATH environment variable, so when rubygems will try to install nio4r and call C compilers, it will call msys ones.
Read here https://rubyinstaller.org/2017/05/25/rubyinstaller-2.4.1-1-released.html for more info about MSYS2 and DevKit in RubyInstaller

rails cannot install nokogiri w Mavericks & rbenv

running OSX 10.9.4 and XCode 5.1.1, I switched recently from rvm to Rbenv, so I need to reinstall some gems, not a big deal, but...
I am stuck w Nokogiri gem installation, even after downloading and installing october version of the XCode command line tool and running :
sudo xcode-select -s /Library/Developer/CommandLineTools/
I also installed libxml2 libxslt w brew
I am still getting an error, is there any way to solve this issue ?
yves$ 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/yves/.rbenv/versions/2.1.2/bin/ruby extconf.rb
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/yves/.rbenv/versions/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
/Users/yves/.rbenv/versions/2.1.2/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/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:1067:in `block in have_header'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
from /Users/yves/.rbenv/versions/2.1.2/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:120:in `each_iconv_idir'
from extconf.rb:137:in `iconv_prefix'
from extconf.rb:427: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:422:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/yves/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.3 for inspection.
Results logged to /Users/yves/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.3/gem_make.out
when installing libxml2 libxslt I got a warning , it may interfere with the nokogiri installation ?
yves$ brew install libxml2 libxslt
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libxml2-2.9
######################################################################## 100.0%
==> Pouring libxml2-2.9.1.mavericks.bottle.1.tar.gz
==> 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
what should i do next ? thanks for your advices
I got the same error a few weeks ago. This is how I solved it:
You'll have to install the broken libraries manually. Use Homebrew, which is a package manager for OS X. Make sure you update first brew update, then install the libraries:
brew install libxml2 libxslt
brew link libxml2 libxslt
You may have to install libiconv from source:
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar xvfz libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
make
sudo make install
And then you should be able to install the gem.
Quoted from documentation here:
http://nokogiri.org/tutorials/installing_nokogiri.html#homebrew_09
You may also need to run rbenv rehash after installing the libraries.
I have found the solution on one of the forums:
https://github.com/sparklemotion/nokogiri/issues/1111
After almost a week of searching this finally did the trick:
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
GL
I got the same issue few days ago and this thread helped me
https://github.com/sparklemotion/nokogiri/issues/1111
Finally the command which worked for me
gem install nokogiri -- --with-xslt-dir=/usr/local/opt/libxslt

Installing nokogiri after a Mavericks upgrade -- entities.c is missing?

I'm running into the same problem most people are running into with nokogiri install on post-Mavericks upgrade machine.
/Users/lunchbag/.rvm/rubies/ruby-2.0.0-p451/bin/ruby extconf.rb --with-xml2-include=/usr/local/Cellar/libx/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin13.1.0/ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... ERROR, review 'tmp/x86_64-apple-darwin13.1.0/ports/libxml2/2.8.0/configure.log' to see what happened.
*** 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/lunchbag/.rvm/rubies/ruby-2.0.0-p451/bin/ruby
/Users/lunchbag/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.3/lib/mini_portile.rb:278:in `block in execute': Failed to complete configure task (RuntimeError)
from /Users/lunchbag/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.3/lib/mini_portile.rb:270:in `chdir'
from /Users/lunchbag/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.3/lib/mini_portile.rb:270:in `execute'
from /Users/lunchbag/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.3/lib/mini_portile.rb:65:in `configure'
from /Users/lunchbag/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.3/lib/mini_portile.rb:108:in `cook'
from extconf.rb:101:in `block in <main>'
from extconf.rb:119:in `call'
from extconf.rb:119:in `block in <main>'
from extconf.rb:109:in `tap'
from extconf.rb:109:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/lunchbag/.rvm/gems/ruby-2.0.0-p451/gems/nokogiri-1.6.1 for inspection.
Results logged to /Users/lunchbag/.rvm/gems/ruby-2.0.0-p451/extensions/x86_64-darwin-13/2.0.0/nokogiri-1.6.1/gem_make.out
My configure.log shows the following error:
configure: error: cannot find sources (entities.c) in /usr/local/lib/node_modules/npm or ..
I've tried installing/reinstalling/unlinking/relinking libxml2, libxslt.
Any other tips? Thanks!
Installing the libraries with Homebrew and setting NOKOGIRI_USE_SYSTEM_LIBRARIES=1 before 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:
$ 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"
Had the exact same problem. I latched onto why is it looking for (entities.c) in
/usr/local/lib/node_modules/npm or ..
I'm no expert but npm probably doesn't have make files in it.
I got nokogiri to install by removing npm from my ~/.bash_profile (the other place to check might be ~/.profile). Here was how my .bash_profile looked:
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/lib/node_modules/npm:/usr/local/mysql/bin:$PATH"
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
source ~/.profile
You can see npm in the first line, I just deleted that, reloaded my terminal (so it stopped looking in npm directory for stuff) and did sudo gem install nokogiri AND IT WORKED :)!!!
As a side note npm commands seem to be working so I don't know why I had that path in my .bash_profile
Hope this helps, first answer on SO.
Here is my solution for Yosemite and libxml2 installed via brew
gem install nokogiri -v '1.6.5' -- --use-system-libraries=true --with-xml2-include=/usr/include/libxml2

Issue with installing ImageMagick and rmagick on Mountain Lion

I am facing issues with installing rmagick in mountain lion. I have installed Xcode 4.4 and developer tools. Still facing this issue.
Installing rmagick (2.13.1) with native extensions Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/bundler/issues so that we can fix it. Thanks!
/Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:552:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/Users/mohit/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
extconf.rb:128: Use RbConfig instead of obsolete and deprecated Config.
checking for clang... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.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
--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/mohit/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
/Users/mohit/.rvm/rubies/ruby-1.9.3-p125/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 /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:931:in `block in have_header'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:930:in `have_header'
from extconf.rb:193:in `<main>'
Gem files will remain installed in /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/rmagick-2.13.1 for inspection.
Results logged to /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:530:in `block in build_extensions'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:505:in `each'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:505:in `build_extensions'
from /Users/mohit/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:180:in `install'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/source.rb:90:in `block in install'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/rubygems_integration.rb:82:in `preserve_paths'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/source.rb:89:in `install'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:73:in `block in install_gem_from_spec'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/rubygems_integration.rb:97:in `with_build_args'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:72:in `install_gem_from_spec'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:56:in `block in run'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:55:in `run'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/installer.rb:12:in `install'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/cli.rb:220:in `install'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor/task.rb:22:in `run'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor.rb:263:in `dispatch'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/lib/bundler/vendor/thor/base.rb:386:in `start'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.0/bin/bundle:13:in `<top (required)>'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/bin/bundle:19:in `load'
from /Users/mohit/.rvm/gems/ruby-1.9.3-p125/bin/bundle:19:in `<main>'
I just updated to Mountain Lion this morning and had rmagick troubles. I had installed ImageMagick through homebrew at some point in the past, so this worked for me after installing the new commandline tools through xcode's preferences window.
brew update
brew uninstall ImageMagick
brew install ImageMagick
gem uninstall rmagick
gem install rmagick
I didn't have to get funky with gcc like some above posts mentioned.
I finally solved this using:
$ cd /usr/local/Cellar/imagemagick/6.8.0-10/lib
$ ln -s libMagick++-Q16.7.dylib libMagick++.dylib
$ ln -s libMagickCore-Q16.7.dylib libMagickCore.dylib
$ ln -s libMagickWand-Q16.7.dylib libMagickWand.dylib
The solution comes from https://coderwall.com/p/wnomjg
I was getting the same
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
did it as it says in https://gist.github.com/1860511
So after updating my mac pro to Mountain Lion, my ruby environment started screaming with different errors one after another.
After 1-2 hours of trial - error and googling, here is how I fixed my ruby on rails environment.
First I got ruby env errors.It was not detecting git commands and Bundler was screaming with
errors when I ran foreman start
Step1 : Update XCode. Get the latest one Xcode 4.6
Mountain Lion does not come with ruby headers installed before hand, so you need to do this manually from XCode. Go to Xcode Preferences/Downloads.
Install Command Line Tools
Step2: Install XQuartz
Logout and Login again. (You might not need this as imagemagick formula has been updated
Step 3: Now your ruby env would start speaking about Imagemagick errors
Do this:
brew update
brew uninstall imagemagick
brew install --fresh imagemagick
gem uninstall rmagick 2.13.2
gem install rmagick
After trying the last one, now it will give you native extension errors like this
Installing rmagick (2.13.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/priyanka/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for /usr/bin/gcc-4.2... no
No C compiler found in ${ENV['PATH']}. See mkmf.log for details.
*** 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/priyanka/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
Gem files will remain installed in /Users/priyanka/.rvm/gems/ruby-1.9.2-p180/gems/rmagick- 2.13.1 for inspection.
Results logged to /Users/priyanka/.rvm/gems/ruby-1.9.2-p180/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
An error occured while installing rmagick (2.13.1), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.1'` succeeds before bundling.
Step 4:
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
This should fix all issues that Mountain Lion gifted you after the upgrade.
Just run bundle.
Try changing your path such that /usr/local/bin is inserter before /usr/bin. I found this running brew doctor and it allowed me to finish compiling imagemagick.
Here is a quick summary of how I was able to get RMagick work, after several tries. I feel the following is the best way to get it without going to the pains of downloading source tarballs and compilation - leave that to experts
You need to have Xcode and Command Line Tools installed for gcc/g++ etc. Command line tools do not get installed automatically with Xcode, go Preferences and install it
Next install Macport
Install Homebrew as well
Make sure you have X11 server installed - if not install it - sudo
port install -v xorg-server. I use -v option as it is a long install
and you might wonder whether it is doing something or just hanging
Install pkgconfig - sudo brew install pkgconfig
now it is time to install ImageMacick - sudo port install -v
ImageMagick do not use brew to install ImageMagick - it does not install all the dependencies and delegates properly.
once ImageMagick is installed - set DISPLAY env variable - export DISPLAY=:0.0 - better still put it in your .profile
Now test your ImageMagick installation
start X11 server (after X11 server installation it is will there in
your App List)
from command line run - $convert logo: logo.gif; identify logo.gif; display logo.gif - it should pop up a window displaying logo.gif
also run a command from command line - $convert -list configure | grep -i delegates. It should output the following DELEGATES bzlib fftw fontconfig freetype gs jpeg jng lcms2 lzma png tiff x11 xml zlib
Now you should be set to run
sudo gem install RMagick
After RMagick is installed successfully - check where it is installed, go to examples directory within and run some of the programs.
No solutions were working for me, eventually I ran brew doctor and discovered that I needed to link imagemagick with brew link --overwrite imagemagick
I had similar issue but on El Captain. Better explained here.
Fixed after installing xcode command-line tools:
xcode-select --install
You need to install XCode 4.4, command line tools, etc. Check out the full listing here:
http://tektastic.com/2012/07/getting-rmagic-and-friends-to-work-on.html
I found the solution for me was a combination of the steps listed above, at http://tektastic.com/2012/07/getting-rmagic-and-friends-to-work-on.html and here http://robots.thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion, although I didn't have to do all the steps listed in either post. But I did need to install the command line tools from XCode, I missed that detail the first few times. I also had to install gcc-4.2 using homebrew, and make a sym link to that installation in my bin directory.
I could be confused about what's going on with the different compilers, but I would be cautious about sym linking /usr/bin/gcc to /usr/bin/gcc-4.2 (which may in turn be a link to gcc-4.2 installed by homebrew). Before I realized I needed to install the command line tools, I had tried making that sym link and then I started seeing other gem build failures. Installing the command line tools fixed those issues - I believe the xcode command line tools made it a sym link to llvm-gcc-4.2.
I just installed rmagick 2.13.2 and this issue is gone.

ROR + Unable to install tiny_tds

Here I am trying to fetch data from MS-SQL Server 2008 to my Rails application on Ubuntu 10. But I am unable to install tiny_tds. I follow the step given at github. But no response. Please guide me to setup correctly.
Used gem command :: gem install tiny_tds
This command as well :: gem install tiny_tds –with-freetds-include=/usr/local/include/freetds –with-freetds-lib=/usr/local/lib
Error :
Installing tiny_tds (0.4.5) with native extensions /home/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/rubygems/installer.rb:483:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/home/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
looking for library directory /home/.rvm/gems/ruby-1.9.2-p180#rails3/lib ... no
looking for library directory /home/.rvm/gems/ruby-1.9.2-p180#rails3/lib/freetds ... no
looking for library directory /home/.rvm/gems/ruby-1.9.2-p180#global/lib ... no
looking for library directory /home/.rvm/gems/ruby-1.9.2-p180#global/lib/freetds ... no
looking for library directory /home/.rvm/rubies/ruby-1.9.2-p180/lib ... yes
checking for main() in -lsybdb... no
looking for library directory /home/.rvm/rubies/ruby-1.9.2-p180/lib/freetds ... no
looking for library directory /home/.rvm/lib ... yes
checking for main() in -lsybdb... no
looking for library directory /home/.rvm/lib/freetds ... no
looking for library directory /home/lib ... no
looking for library directory /home/lib/freetds ... no
looking for library directory /usr/local/lib ... yes
checking for main() in -lsybdb... no
looking for library directory /usr/local/lib/freetds ... no
looking for library directory /usr/lib ... yes
checking for main() in -lsybdb... no
-----
Can not find FreeTDS's db-lib or include directory.
-----
*** 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=/home/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
--enable-iconv
--disable-iconv
--enable-iconv
--disable-iconv
--with-freetds-dir
--without-freetds-dir
--with-freetds-include
--without-freetds-include=${freetds-dir}/include
--with-freetds-lib
--without-freetds-lib=${freetds-dir}/lib
--enable-lookup
--disable-lookup
--with-sybdblib
--without-sybdblib
--with-sybdblib
--without-sybdblib
--with-sybdblib
--without-sybdblib
--with-sybdblib
--without-sybdblib
looking for library directory /usr/lib/freetds ... no
looking for library directory /usr/local/ruby/lib ... no
looking for library directory /usr/local/ruby/lib/freetds ... no
Gem files will remain installed in /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/tiny_tds-0.4.5 for inspection.
Results logged to /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/tiny_tds-0.4.5/ext/tiny_tds/gem_make.out
from /home/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/rubygems/installer.rb:486:in `block in build_extensions'
from /home/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/rubygems/installer.rb:446:in `each'
from /home/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/rubygems/installer.rb:446:in `build_extensions'
from /home/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/rubygems/installer.rb:198:in `install'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/source.rb:101:in `block in install'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/rubygems_integration.rb:78:in `preserve_paths'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/source.rb:91:in `install'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/installer.rb:58:in `block (2 levels) in run'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/rubygems_integration.rb:93:in `with_build_args'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/installer.rb:57:in `block in run'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/spec_set.rb:12:in `block in each'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/spec_set.rb:12:in `each'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/spec_set.rb:12:in `each'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/installer.rb:49:in `run'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/installer.rb:8:in `install'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/cli.rb:222:in `install'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/vendor/thor/task.rb:22:in `run'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/lib/bundler/vendor/thor/base.rb:389:in `start'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/gems/bundler-1.0.15/bin/bundle:13:in `<top (required)>'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/bin/bundle:19:in `load'
from /home/.rvm/gems/ruby-1.9.2-p180#rails3/bin/bundle:19:in `<main>'
Did you install freeTDS prior to install the gem?
sudo apt-get install freetds-dev
Then
gem install tiny_tds
The answer above is correct, this is just an additional note for those mac folks that prefer homebrew
It command is essentially the exact same:
brew install freetds
As ar3 says, the answer above is correct. For those on CentOS, the RPM is freetds-devel, not freetds-dev (in case you're as soft with sysadmin as I am).
yum install freetds-devel
For mac users first install freetds by gem install tiny_tds
then get the freetds path by ls /opt/homebrew/Cellar/freetds
my version is 1.3.10
then
gem install tiny_tds -- --with-freetds-dir=/opt/homebrew/Cellar/freetds/1.3.10
Try with this,
Download freetds from following link and install it
freetds download link
Install with following instructions:
cd /home/user/Downloads/
tar -zxvf freetds-1.00.23.tar.gz
Then
cd freetds-1.00.23/
./configure
make
sudo make install
After freetds installation complete, try with bundle install
This will solve freetds dependency issue.

Resources