I installed Rails 4.2.3 on Mac OS X Yosemite, but when I try to start the server, I get this error message
Companys-MacBook-Pro:App MyUser$ rails server
Could not find nokogiri-1.6.1 in any of the sources
Run `bundle install` to install missing gems.
Companys-MacBook-Pro:App MyUser$
so I tried this
sudo gem install nokogiri -v=1.6.1
then I got these errors
Companys-MacBook-Pro:~ MyUser$ sudo gem install nokogiri -v=1.6.1
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin14.4.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 /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin14.4.0/libxml2/2.8.0)...
Extracting libxslt-1.1.26.tar.gz into tmp/x86_64-apple-darwin14.4.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 /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin14.4.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... no
-----
libxml2 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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-libxslt-config
--without-libxslt-config
--with-pkg-config
--without-pkg-config
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--with-libiconv-config
--without-libiconv-config
--with-pkg-config
--without-pkg-config
--with-iconvlib
--without-iconvlib
--with-xml2lib
--without-xml2lib
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1/ext/nokogiri/gem_make.out
Companys-MacBook-Pro:~ MyUser$
I then followed the instructions on nokogiri website to install libxslt, libxml2, and libiconv
Companys-MacBook-Pro:~ MyUser$ brew install libxml2
Warning: libxml2-2.9.2 already installed
Companys-MacBook-Pro:~ MyUser$ brew install libxslt
Warning: libxslt-1.1.28_1 already installed
Companys-MacBook-Pro:~ MyUser$ brew install libiconv
Error: No available formula for libiconv
==> Searching formulae...
==> Searching taps...
Companys-MacBook-Pro:~ MyUser$
and still no luck. I also tried
Companys-MacBook-Pro:~ MyUser$ sudo gem install nokogiri
Building native extensions. This could take a while...
Successfully installed nokogiri-1.6.6.2
Parsing documentation for nokogiri-1.6.6.2
unable to convert "\xCA" from ASCII-8BIT to UTF-8 for lib/nokogiri/nokogiri.bundle, skipping
1 gem installed
Companys-MacBook-Pro:~ MyUser$
but rails server still does not start because it requires nokogiri 1.6.1
Companys-MacBook-Pro:App MyUser$ rails server
Could not find nokogiri-1.6.1 in any of the sources
Run `bundle install` to install missing gems.
Companys-MacBook-Pro:App MyUser$
Anyone has an idea what's going on here?
EDIT 1
I did run bundle install and still the same issue ; this is the output
Companys-MacBook-Pro:App MyUser$ bundle install
Fetching gem metadata from http://rubygems.org/............
Fetching version metadata from http://rubygems.org/...
Fetching dependency metadata from http://rubygems.org/..
Resolving dependencies...
Using rake 0.9.2.2
Using multi_json 1.0.3
Using activesupport 3.1.0
Using bcrypt-ruby 3.0.0
Using builder 3.0.0
Using i18n 0.6.0
Using activemodel 3.1.0
Using erubis 2.7.0
Using rack 1.3.2
Using rack-cache 1.0.3
Using rack-mount 0.8.3
Using rack-test 0.6.1
Using hike 1.2.1
Using tilt 1.3.3
Using sprockets 2.0.0
Using actionpack 3.1.0
Using mime-types 1.16
Using polyglot 0.3.2
Using treetop 1.4.10
Using mail 2.3.0
Using actionmailer 3.1.0
Using arel 2.2.1
Using tzinfo 0.3.29
Using activerecord 3.1.0
Using activeresource 3.1.0
Using addressable 2.3.6
Using bundler 1.10.6
Using coderay 1.0.8
Using coffee-script-source 1.1.2
Using execjs 1.2.4
Using coffee-script 2.2.0
Using rack-ssl 1.3.2
Using rdoc 3.9.4
Using thor 0.14.6
Using railties 3.1.0
Using coffee-rails 3.1.0
Using crack 0.3.1
Using diff-lcs 1.1.3
Using multipart-post 1.2.0
Using faraday 0.7.6
Using git 1.2.6
Using hashie 1.2.0
Using oauth2 0.5.2
Using github_api 0.4.10
Using highline 1.6.21
Using mini_portile 0.5.3
Installing nokogiri 1.6.1 with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-xml2-dir=/usr --with-xslt-dir=/opt/local --with-iconv-dir=/opt/local
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin14.4.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 /private/var/folders/x4/01wntm8j66lf6mwbtmg8t3lm0000gn/T/bundler20150801-30338-1m943xrnokogiri-1.6.1/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin14.4.0/libxml2/2.8.0)...
Extracting libxslt-1.1.26.tar.gz into tmp/x86_64-apple-darwin14.4.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 /private/var/folders/x4/01wntm8j66lf6mwbtmg8t3lm0000gn/T/bundler20150801-30338-1m943xrnokogiri-1.6.1/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin14.4.0/libxslt/1.1.26)...
checking for libxml/parser.h... no
-----
libxml2 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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/lib
--with-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-libxslt-config
--without-libxslt-config
--with-pkg-config
--without-pkg-config
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--with-libiconv-config
--without-libiconv-config
--with-pkg-config
--without-pkg-config
Gem files will remain installed in /var/folders/x4/01wntm8j66lf6mwbtmg8t3lm0000gn/T/bundler20150801-30338-1m943xrnokogiri-1.6.1/gems/nokogiri-1.6.1 for inspection.
Results logged to /var/folders/x4/01wntm8j66lf6mwbtmg8t3lm0000gn/T/bundler20150801-30338-1m943xrnokogiri-1.6.1/gems/nokogiri-1.6.1/ext/nokogiri/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.
Companys-MacBook-Pro:App MyUser$
One of issues was that you were manually installing Nokogiri 1.6.6.2, but not including the nokogiri gem entry in your Gemfile. Bundler will specifically only show your app the gems that are listed in the file.
It wasn't clear to me if you were tied to nokogiri 1.6.1 because it was a dependency of another gem. If there was another gem calling for 1.6.1 then you would investigate a newer version of that gem, which hopefully depended on the newer Nokogiri. bundle update <othergem> would attempt to do so.
Just wanted to be clear that I wasn't suggesting modifying another gem's dependencies in your lock file as they were set for a reason by that gem's author.
Since you initially specified gem 'nokogiri', '~> 1.6.1' in your Gemfile you were locked to that after the first bundle install. bundle update nokogiri would try to update you to the latest. Or manually changing the Gemfile to 1.6.6.2 or more loosely ~> 1.6 or 1.6.6.
Also, as #the Tin Man mentioned using sudo install to put gems into the Apple system ruby isn't the best way to go. I definitely recommend using one of the Ruby version managers like RVM or rbenv as he linked in his comment.
Related
Im using WSL (ubuntu) for windows 10 with RVM version 1.29.12.
Ruby version is 2.4.1p11. Bundler version 1.16.4.
When I execute bundle install, It stops on nokogiri and throws this error:
Fetching gem metadata from https://rubygems.org/............
Using rake 12.3.0
Using concurrent-ruby 1.0.5
Using i18n 0.9.1
Using minitest 5.10.3
Using thread_safe 0.3.6
Using tzinfo 1.2.4
Using activesupport 5.1.4
Using builder 3.2.3
Using erubi 1.7.0
Using mini_portile2 2.3.0
Fetching nokogiri 1.8.1
Installing nokogiri 1.8.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
checking if the C compiler accepts ... no
Building nokogiri using system libraries.
pkg-config could not be used to find libxml-2.0
Please install either `pkg-config` or the pkg-config gem per
gem install pkg-config -v "~> 1.1"
pkg-config could not be used to find libxslt
Please install either `pkg-config` or the pkg-config gem per
gem install pkg-config -v "~> 1.1"
pkg-config could not be used to find libexslt
Please install either `pkg-config` or the pkg-config gem per
gem install pkg-config -v "~> 1.1"
ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed.
*** 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/mike/.rvm/rubies/ruby-2.4.1/bin/$(RUBY_BASE_NAME)
--help
--clean
--use-system-libraries
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-libxslt-config
--without-libxslt-config
--with-exslt-dir
--without-exslt-dir
--with-exslt-include
--without-exslt-include=${exslt-dir}/include
--with-exslt-lib
--without-exslt-lib=${exslt-dir}/lib
--with-libexslt-config
--without-libexslt-config
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/mnt/c/Users/test/vendor/bundle/ruby/2.4.0/extensions/x86_64-linux/2.4.0/nokogiri-1.8.1/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /mnt/c/Users/test/vendor/bundle/ruby/2.4.0/gems/nokogiri-1.8.1 for inspection.
Results logged to /mnt/c/Users/test/vendor/bundle/ruby/2.4.0/extensions/x86_64-linux/2.4.0/nokogiri-1.8.1/gem_make.out
An error occurred while installing nokogiri (1.8.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.8.1' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
view_source_map was resolved to 0.1.4, which depends on
rails was resolved to 5.1.4, which depends on
actioncable was resolved to 5.1.4, which depends on
actionpack was resolved to 5.1.4, which depends on
actionview was resolved to 5.1.4, which depends on
rails-dom-testing was resolved to 2.0.3, which depends on
nokogiri
I have tried several suggestions I found online like doing
gem install pkg-config -v "~> 1.1"
or
sudo apt-get install libxml2-dev libxslt-dev
but I can't seem to get rid of the error.
I also tried installing the nokogiri separately and then executed bundle install again but the same issue still occurs.
Thanks in advance.
Try this. This is instructing bundler to look for libraries
bundle config build.nokogiri --use-system-libraries
bundle install
If above doesn't work. check your log files. In most scenarios some libraries are missed.
sudo apt-get install zlib1g-dev
sudo apt-get install libxml2-dev
sudo apt-get install libxslt-dev
I am getting an error and bundle install fails:
An error occurred while installing nokogiri (1.9.1), and Bundler cannot continue. Make sure that gem install nokogiri -v '1.9.1' --source 'https://rubygems.org/' succeeds before bundling.
I have tried many commands from stack overflow but no luck yet.
After reading some posts about the issue I added the following environment variables but the bundle install still fails.
export PATH="/usr/local/opt/libxslt/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/libxslt/lib"
export CPPFLAGS="-I/usr/local/opt/libxslt/include"
sudo gem install nokogiri -v "1.9.1" -- --use-system-libraries
Building native extensions with: '--use-system-libraries'
This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/wiii/.rbenv/versions/2.1.5/bin/ruby extconf.rb --use-system-libraries
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using system libraries.
checking for xmlParseDoc() in libxml/parser.h... yes
checking for xsltParseStylesheetDoc() in libxslt/xslt.h... no
checking for xsltParseStylesheetDoc() in -lxslt... no
checking for xsltParseStylesheetDoc() in -llibxslt... no
-----
libxslt is missing. Please locate mkmf.log to investigate how it is failing.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/wiii/.rbenv/versions/2.1.5/bin/ruby
--help
--clean
--use-system-libraries
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-libxslt-config
--without-libxslt-config
--with-exslt-dir
--without-exslt-dir
--with-exslt-include
--without-exslt-include=${exslt-dir}/include
--with-exslt-lib
--without-exslt-lib=${exslt-dir}/lib
--with-libexslt-config
--without-libexslt-config
--with-xsltlib
--without-xsltlib
--with-libxsltlib
--without-libxsltlib
extconf failed, exit code 1
Debugging info are attached below:
$ which ruby
/Users/wiii/.rbenv/shims/ruby
$ which bundle
/Users/wiii/.rbenv/shims/bundle
$ which gem
/Users/wiii/.rbenv/shims/gem
$ ruby --version
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin19.0]
$ bundle --version
Bundler version 1.17.3
$ gem --version
2.2.2
Homebrew
% brew list
ansible kind libxslt openssl#1.0 ruby-build
autoconf kubectx libyaml openssl#1.1 sqlite
gdbm kubernetes-cli mpdecimal pkg-config tcl-tk
go libgcrypt mysql#5.7 protobuf tomcat#8
htop libgpg-error ncurses python#3.9 xz
icu4c libiconv node rbenv
k9s libxml2 openjdk readline
intellij-idea
Could anyone share some thoughts on what might be causing the issues here?
Nokogiri is an open source software library to parse HTML and XML in Ruby. It depends on libxml2 and libxslt to provide its functionality. without it Rails is non-functional.
it seems as if your macOS is missing some essential libraries required for nokogiri to run on your computer.
you can go ahead and first uninstall nokogiri and any other interfering library that you might have installed during your endeavor to solve this issue
run brew uninstall nokogiri
upon uninstalling, you can run brew install libxml2 libxslt to install the most essential libraries using brew
after that, run gem install nokogiri --platform=ruby -- --use-system-libraries to successfully install nokogiri
I'm just getting going learning Rails and am struggling to get out of the blocks....
$ rails new sample_app
$ cd sample_app
$ bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Using rake 10.5.0
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.4
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Using rack 1.6.4
Using mime-types 2.99
Using arel 6.0.3
Using debug_inspector 0.0.2
Using byebug 8.2.2
Using coffee-script-source 1.10.0
Using execjs 2.6.0
Using thor 0.19.1
Using concurrent-ruby 1.0.0
Using multi_json 1.11.2
Using bundler 1.11.2
Using sass 3.4.21
Using tilt 2.0.2
Using spring 1.6.3
Using sqlite3 1.3.11
Using rdoc 4.2.2
Using tzinfo 1.2.2
Installing nokogiri 1.6.7.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/pschloss/Desktop/rails/sample_app/vendor/bundle/ruby/2.0.0/gems/nokogiri-1.6.7.2/ext/nokogiri
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20160218-90999-1e1suiq.rb extconf.rb --use-system-libraries
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using system libraries.
checking for xmlParseDoc() in libxml/parser.h... no
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
-----
libxml2 is missing. Please locate mkmf.log to investigate how it is failing.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--help
--clean
--use-system-libraries
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-libxslt-config
--without-libxslt-config
--with-exslt-dir
--without-exslt-dir
--with-exslt-include
--without-exslt-include=${exslt-dir}/include
--with-exslt-lib
--without-exslt-lib=${exslt-dir}/lib
--with-libexslt-config
--without-libexslt-config
--with-xml2lib
--without-xml2lib
--with-libxml2lib
--without-libxml2lib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/pschloss/Desktop/rails/sample_app/vendor/bundle/ruby/2.0.0/extensions/universal-darwin-15/2.0.0/nokogiri-1.6.7.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/pschloss/Desktop/rails/sample_app/vendor/bundle/ruby/2.0.0/gems/nokogiri-1.6.7.2 for inspection.
Results logged to /Users/pschloss/Desktop/rails/sample_app/vendor/bundle/ruby/2.0.0/extensions/universal-darwin-15/2.0.0/nokogiri-1.6.7.2/gem_make.out
Using rack-test 0.6.3
Using mail 2.6.3
Using binding_of_caller 0.7.2
Using coffee-script 2.4.1
Using uglifier 2.7.2
Using sprockets 3.5.2
Using sdoc 0.4.1
Using activesupport 4.2.5.1
An error occurred while installing nokogiri (1.6.7.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.7.2'` succeeds before bundling.
So then I finally get nokogiri installed...
$ gem install nokogiri -- --use-system-libraries
Building native extensions with: '--use-system-libraries'
This could take a while...
Successfully installed nokogiri-1.6.7.2
Parsing documentation for nokogiri-1.6.7.2
Done installing documentation for nokogiri after 1 seconds
1 gem installed
And then I redo bundle install and I get the same error I had before.
Also if I do:
$ bundle config build.nokogiri --use-system-libraries & bundle install
I get the same errors.
Here are some specs:
$ rails --version
Rails 4.2.5.1
$ ruby --version
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-darwin15]
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.11.1
BuildVersion: 15B42
Any ideas on what I'm doing wrong here?
I'll try to give a bit of background information (since you're just starting out and this might help with the ride).
In Ruby and Rails land you'll be installing a lot of gems ("libraries").
Sometimes libraries need/want to be fast and therefore a part of the gem is written in C. Installing these parts can be difficult, thats whats happening at
Installing nokogiri 1.6.7.2 with native extensions
These native extensions need to be compiled and dynamically linked and have gained a reputation for being complicated to install so this might happen more often than you'd like :(.
In Nokogiris case though, you are lucky since they have a whole page dedicated to fixing installation issues here.
To get to your case, the regular gem install works, my guess is you need to tell bundler to use system libraries
export NOKOGIRI_USE_SYSTEM_LIBRARIES=1
bundle install
Edit:
I missed that you were already specifying that, maybe try:
--with-xml2-include=/wherever/brew/install/it
and have a look here.
Your OS is lacking of some libraries like libxml2.
So try:
brew install libxml2
brew install libxslt
One of my developers have updated Nokogiri, and when pulling the updated Gemfile my bundle install fails.
➜ my-project git:(master) bundle install
Fetching source index from https://rubygems.org/
Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.3
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.3
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/me/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb --use-system-libraries
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using system libraries.
libxml2 version 2.6.21 or later is required!
*** 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/me/.rvm/rubies/ruby-2.1.2/bin/ruby
--help
--clean
--use-system-libraries
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-libxslt-config
--without-libxslt-config
--with-exslt-dir
--without-exslt-dir
--with-exslt-include
--without-exslt-include=${exslt-dir}/include
--with-exslt-lib
--without-exslt-lib=${exslt-dir}/lib
--with-libexslt-config
--without-libexslt-config
extconf failed, exit code 1
Gem files will remain installed in /Users/me/.rvm/gems/ruby-2.1.2#my-project/gems/nokogiri-1.6.7 for inspection.
Results logged to /Users/me/.rvm/gems/ruby-2.1.2#my-project/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.7/gem_make.out
An error occurred while installing nokogiri (1.6.7), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.7'` succeeds before bundling.
As suggested in "Failing to install Nokogiri gem" I have unsuccessfully tried to run:
bundle config build.nokogiri --use-system-libraries
bundle install
As suggested in "Failing to install Nokogiri gem" I also tried:
gem install nokogiri -- --use-system-libraries
and:
gem install nokogiri -v 1.6.5 -- --use-system-libraries
My OS version is El Capitan 10.11.2, and I have checked that the Xcode licence agreement has been accepted.
Any ideas how to get the Nokogiri installation to succeed?
You should install xcode-select packages first, then try installing nokogiri again. Try these commands,
xcode-select --install
then try
gem install nokogiri
with whatever Nokogiri version you want.
Nokogiri depends on multiple libraries like libxslt, libxml and zlib. Dev versions (including source) of these should be installed before installing Nokogiri in any Linux distribution. For OS X, the above command should work I guess.
The actual solution is in the comments below.
Try this :
gem install nokogiri -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib/
And then run
bundle update
I hope this could help you :)
I you're using homebrew to maintain libraries like libml on your mac, the following command on your mac might help:
gem install nokogiri -v '1.6.8' -- --use-system-libraries --with-xml2-include=/usr/local/Cellar/libxml2/2.9.2/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.2/lib/
just ensure that the path for libxml is same as mine unless brew changes with the next version. You can check this by running the below command:
brew info libxml2
Edit Updated work good with MacOS Sierra :
xcode-select --install
Add gem "nokogiri", ">= 1.6.7.rc3" in your Gemfile
and then run
bundle install
try to:
apt-get install ruby-nokogiri
bundle install
Thank you for posting this! I finally got nokogirl to run with bundle install correctly for my app after running the following:
bundle config build.nokogiri --use-system-libraries
Updating Xcode and Command Line Tools fixed all the errors for me. After that I could install Nokogiri with gem install nokogiri and after that gem install rails worked fine.
The following steps worked for me
ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]
Run the following to install RVM and the latest stable version of Ruby:
\curl -L https://get.rvm.io | bash -s stable --ruby
Install the Ruby interpreter:
rvm install 2.1.0 --autolibs=enable
After that's finished installing, run:
source /Users/{your_user_name}/.rvm/scripts/rvm
Run:
ruby -v
ruby 2.1.0p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]
==> sudo gem install bundler
Fetching: bundler-1.14.6.gem (100%)
Successfully installed bundler-1.14.6
Parsing documentation for bundler-1.14.6
Installing ri documentation for bundler-1.14.6
Done installing documentation for bundler after 4 seconds
1 gem installed
i'm new in rails and i don't understand why Nokogiri don't want to install while i try to bundle install :
barnab21:sample_app barnab21$ sudo bundle install
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as
root will break this application for all non-root users on this machine.
Fetching gem metadata from http://rubygems.org/.........
Using rake 0.9.6
Using abstract 1.0.0
Using activesupport 3.0.7
Using builder 2.1.2
Using i18n 0.5.4
Using activemodel 3.0.7
Using erubis 2.6.6
Using rack 1.2.8
Using rack-mount 0.6.14
Using rack-test 0.5.7
Using tzinfo 0.3.39
Using actionpack 3.0.7
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.2.20
Using actionmailer 3.0.7
Using arel 2.0.10
Using activerecord 3.0.7
Using activeresource 3.0.7
Using diff-lcs 1.1.3
Using mini_portile 0.6.0
Building nokogiri using system libraries.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --use-system-libraries
Building nokogiri using system libraries.
libxml2 version 2.6.21 or later is required!
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--help
--clean
--use-system-libraries
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-libxslt-config
--without-libxslt-config
--with-pkg-config
--without-pkg-config
--with-exslt-dir
--without-exslt-dir
--with-exslt-include
--without-exslt-include=${exslt-dir}/include
--with-exslt-lib
--without-exslt-lib=${exslt-dir}/lib
--with-libexslt-config
--without-libexslt-config
--with-pkg-config
--without-pkg-config
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/nokogiri-1.6.2.1/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.
I try this :
$ xcode-select --install
then gem install nogoriki, but that doesn't work.
I try this, from a other stackoverflow thread :
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"
And :
This could take a while...
Building nokogiri using system libraries.
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --use-system-libraries --with-iconv-dir=/usr/local/opt/libiconv --with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config --with-xslt-config=/usr/local/opt/libxslt/bin/xslt-config
Building nokogiri using system libraries.
libxml2 version 2.6.21 or later is required!
*** 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 Don't know what to try... thx
My mac : Macbook pro retina 15 , mavericks
After $ brew install libxml2 libxslt libiconv I used
gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
and it works for me. You can try it, but change versions of libraries to yours.
So I'm on Yosemite, thought this might help.
The solutions above didn't work for me, but then I realized a couple of the directories had somehow gotten moved into themselves
--with-xml2-include=/usr/local/Cellar/libxml2/2.9.2/include/libxml2/libxml
--with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib/lib
So it might be worth checking all the directories, if anyone still has the problem (ha I don't think I put the files like that, but it's totally possible)
The full command I used:
gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.2/include/libxml2/libxml --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.2/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib/lib
got same problem in Redhat linux 6
you need to install packages libxml2 & libxml2-devel and libxslt & libxslt-devel.
{you need to install libgcrypt & libgcrpt-devel as it is required to install above packages }
make sure you install latest versions.
if package already exist then you need to upgrade those packages.
just use
rpm -uvh --replacefiles {your_packagename.rpm}
hope it helps. comment if you need more help.