I have a new set up, and I keep getting an error when I am trying to install rails. I have used RVM to use ruby 2.2.2, and I have checked through the config files.
I have followed various tutorials. I have uninstalled gcc ( though i may reinstall xcode )
and I have gone through various tutorials on how to install this
gem install rails [9:00:49]
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/rrobin008c/.rvm/rubies/ruby-2.2.2/bin/ruby -r ./siteconf20150812-28205-1wdgrip.rb extconf.rb
checking if the C compiler accepts -O2 -arch x86_64... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:
Building Nokogiri with a packaged version of libxml2-2.9.2
with the following patches applied:
- 0001-Revert-Missing-initialization-for-the-catalog-module.patch
- 0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch
Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:
gem install nokogiri -- --use-system-libraries
[--with-xml2-config=/path/to/xml2-config]
[--with-xslt-config=/path/to/xslt-config]
If you are using Bundler, tell it to use the option:
bundle config build.nokogiri --use-system-libraries
bundle install
Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.2.tar.gz into tmp/x86_64-apple-darwin14.4.0/ports/libxml2/2.9.2... OK
Running patch with /Users/rrobin008c/.rvm/gems/ruby-2.2.2/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch...
Running 'patch' for libxml2 2.9.2... OK
Running patch with /Users/rrobin008c/.rvm/gems/ruby-2.2.2/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch...
Running 'patch' for libxml2 2.9.2... OK
Running 'configure' for libxml2 2.9.2... ERROR, review '/Users/rrobin008c/.rvm/gems/ruby-2.2.2/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-apple-darwin14.4.0/ports/libxml2/2.9.2/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
--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/rrobin008c/.rvm/rubies/ruby-2.2.2/bin/$(RUBY_BASE_NAME)
--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/rrobin008c/.rvm/gems/ruby-2.2.2/gems/mini_portile-0.6.2/lib/mini_portile.rb:279:in `block in execute': Failed to complete configure task (RuntimeError)
from /Users/rrobin008c/.rvm/gems/ruby-2.2.2/gems/mini_portile-0.6.2/lib/mini_portile.rb:271:in `chdir'
from /Users/rrobin008c/.rvm/gems/ruby-2.2.2/gems/mini_portile-0.6.2/lib/mini_portile.rb:271:in `execute'
from /Users/rrobin008c/.rvm/gems/ruby-2.2.2/gems/mini_portile-0.6.2/lib/mini_portile.rb:66:in `configure'
from /Users/rrobin008c/.rvm/gems/ruby-2.2.2/gems/mini_portile-0.6.2/lib/mini_portile.rb:109:in `cook'
from extconf.rb:278:in `block in process_recipe'
from extconf.rb:177:in `tap'
from extconf.rb:177:in `process_recipe'
from extconf.rb:475:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/rrobin008c/.rvm/gems/ruby-2.2.2/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Users/rrobin008c/.rvm/gems/ruby-2.2.2/extensions/x86_64-darwin-14/2.2.0-static/nokogiri-1.6.6.2/gem_make.out
Manually install nokogiri
gem install nokogiri -v VERSION_YOU_WANT -- --use-system-libraries
Check out "nokogiri gem installation error".
Before you run bundle install, run:
bundle config build.nokogiri --use-system-libraries
or
gem install nokogiri -- --use-system-libraries
After that you can run:
bundle install
For other bugs read the Nokogiri install documentation.
I went through the various tutorials and my output looked like this:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/rrobin008c/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150812-2574-6ejap3.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling breakpoint.c
make: /usr/bin/gcc-4.2: No such file or directory
make: *** [breakpoint.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/rrobin008c/.rvm/gems/ruby-2.2.1/gems/byebug-5.0.0 for inspection.
Results logged to /Users/rrobin008c/.rvm/gems/ruby-2.2.1/extensions/x86_64-darwin-14/2.2.0-static/byebug-5.0.0/gem_make.out
An error occurred while installing byebug (5.0.0), and Bundler cannot continue.
Make sure that `gem install byebug -v '5.0.0'` succeeds before bundling.
The significant part is
make: /usr/bin/gcc-4.2: No such file or directory
After this I asked:
$which gcc
/usr/bin/gcc
Follow "OS X Mountain Lion: gcc-4.2 No such file or directory" and everything should work after that.
I would recommend running
brew doctor
rvm reinstall
rvm reinstall (ruby version here)
gem pristine all
sudo gem install rails
If you get to many error best thing to do is remove rails and ruby completely
first type this
tarun#tarun:~$ which ruby
/home/tarun/.rbenv/shims/ruby
tarun#tarun:~$ which rails
/home/tarun/.rbenv/shims/rails
then copy the path and use this command to remove the file
rm -rf /home/tarun/.rbenv/shims/ruby
rm -rf /home/tarun/.rbenv/shims/rails
and same way you can check which rbenv and which rvm and remove by using this same method.
And use
grep -rl rails
grep -rl ruby
this will show path of all files which have rails keyword.So that you can know that have you removed rails and ruby completely.
And follow steps given here to reinstall it
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-14-04
Related
I am trying to run bundle install after updating the most recent security updates to Rails and Ruby, and cannot install the Nokogumbo gem. I get the following error message:
An error occurred while installing nokogumbo (1.5.0), and Bundler cannot continue.
Make sure that `gem install nokogumbo -v '1.5.0' --source 'https://rubygems.org/'` succeeds before bundling.
I tried running gem install nokogumbo -v '1.5.0' --source 'https://rubygems.org/' and got this:
Building native extensions. This could take a while...
ERROR: Error installing nokogumbo:
ERROR: Failed to build gem native extension.
current directory: /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogumbo-1.5.0/ext/nokogumboc
/Users/<username>/.rbenv/versions/2.6.2/bin/ruby -I /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/2.6.0 -r ./siteconf20190314-8398-fmosg1.rb extconf.rb
checking for xmlNewDoc() in -lxml2... yes
checking for nokogiri.h in /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ext/nokogiri... no
checking if the C compiler accepts -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
Using mini_portile version 2.4.0
checking for iconv.h... yes
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:
Building Nokogiri with a packaged version of libxml2-2.9.9
with the following patches applied:
- 0001-Revert-Do-not-URI-escape-in-server-side-includes.patch
Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:
gem install nokogiri -- --use-system-libraries
[--with-xml2-config=/path/to/xml2-config]
[--with-xslt-config=/path/to/xslt-config]
If you are using Bundler, tell it to use the option:
bundle config build.nokogiri --use-system-libraries
bundle install
Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Activating libxml2 2.9.9 (from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ports/x86_64-apple-darwin18.2.0/libxml2/2.9.9)...
************************************************************************
IMPORTANT NOTICE:
Building Nokogiri with a packaged version of libxslt-1.1.33.
Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:
gem install nokogiri -- --use-system-libraries
[--with-xml2-config=/path/to/xml2-config]
[--with-xslt-config=/path/to/xslt-config]
If you are using Bundler, tell it to use the option:
bundle config build.nokogiri --use-system-libraries
bundle install
************************************************************************
*** 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/<username>/.rbenv/versions/2.6.2/bin/$(RUBY_BASE_NAME)
--with-xml2lib
--without-xml2lib
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--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/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:293:in `verify_file': Downloaded file '/Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ports/archives/libxslt-1.1.33.tar.gz' has wrong hash: expected: 8e36605144409df979cab43d835002f63988f3dc94d5d3537c12796db90e38c8 is: d020ac32fcb0778e2f636fc31ac205f3f00aceec08c61a090fefa30110daaddc (RuntimeError)
from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:61:in `block in extract'
from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:60:in `each'
from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:60:in `extract'
from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:151:in `cook'
from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ext/nokogiri/extconf.rb:365:in `block (2 levels) in process_recipe'
from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ext/nokogiri/extconf.rb:257:in `block in chdir_for_build'
from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ext/nokogiri/extconf.rb:256:in `chdir'
from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ext/nokogiri/extconf.rb:256:in `chdir_for_build'
from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ext/nokogiri/extconf.rb:364:in `block in process_recipe'
from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ext/nokogiri/extconf.rb:262:in `tap'
from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ext/nokogiri/extconf.rb:262:in `process_recipe'
from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.1/ext/nokogiri/extconf.rb:574:in `<top (required)>'
from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from extconf.rb:17:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/nokogumbo-1.5.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/nokogumbo-1.5.0 for inspection.
Results logged to /Users/<username>/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/nokogumbo-1.5.0/gem_make.out
I tried running all the commands that are suggested in that error message as well. With the bundle config command, I got a message that said "You are replacing the current global value of build.nokogiri, which is currently "--use-system-libraries=true" etc.
I also tried manually installing nokogumbo 1.4.7, to see if installing an older version of the gem that I could then upgrade might help. No luck. It doesn't make sense as people who have the same set up as me on their machines have been able to install everything fine.
Anyone have any idea what I could do differently? Thanks!
UPDATE - SOLVED
The fix (for Mojave 10.14) is: gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2 --use-system-libraries
Credit here
I ran into this same issue when trying to run bundler in rails. What worked for me was running
bundle config build.nokogiri --use-system-libraries
bundle config build.nokogumbo --use-system-libraries
bundle install
Setting the --use-system-libraries flag for nokogumbo did the trick.
I try to clone this repo and run bundle install. The bundle process failed and throw this error:
...
Installing nokogiri 1.6.2.1 with native extensions
Building nokogiri using packaged libraries.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/zulhilmizainudin/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20151130-43880-pntnc6.rb extconf.rb
Building nokogiri using packaged libraries.
-----
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/zulhilmizainudin/.rvm/rubies/ruby-2.2.0/bin/$(RUBY_BASE_NAME)
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--enable-cross-build
--disable-cross-build
extconf failed, exit code 1
Gem files will remain installed in /Users/zulhilmizainudin/.rvm/gems/ruby-2.2.0/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /Users/zulhilmizainudin/.rvm/gems/ruby-2.2.0/extensions/x86_64-darwin-14/2.2.0-static/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.
Then I try to run this:
gem install nokogiri -v '1.6.2.1'
And now I get this error:
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/zulhilmizainudin/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20151130-43942-1axq4sj.rb extconf.rb
Building nokogiri using packaged libraries.
-----
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/zulhilmizainudin/.rvm/rubies/ruby-2.2.0/bin/$(RUBY_BASE_NAME)
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--enable-cross-build
--disable-cross-build
extconf failed, exit code 1
Gem files will remain installed in /Users/zulhilmizainudin/.rvm/gems/ruby-2.2.0/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /Users/zulhilmizainudin/.rvm/gems/ruby-2.2.0/extensions/x86_64-darwin-14/2.2.0-static/nokogiri-1.6.2.1/gem_make.out
I tried to follow this answer but I still get the same error above.
I also try to uninstall and install my brew again (based on this answer) and it's still same.
Also, I try this solution but still get the error.
What should I do now to make sure this nokogiri gem installed successfully?
Note: I'm using OSX 10.11.1 El Capitan.
Run these commands:
gem uninstall nokogiri
xcode-select --install
gem install nokogiri
source: http://www.nokogiri.org/tutorials/installing_nokogiri.html#mac_os_x
sometimes mac updates can break xcode CLI so reinstalling can fix the issue:
https://github.com/sparklemotion/nokogiri/issues/1445
What worked for me (on macOS Sierra) was a combination of Sam's answer and the following:
gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2 --use-system-libraries
I had a similar issue with 1.6.7.2 when bundle installing on codeship with ruby 2.3.
What worked for me was adding:
bundle config build.nokogiri --use-system-libraries
before
bundle install
If you're using bundle:
brew install libxml2
# If using Bundle
bundle config build.nokogiri --use-system-libraries \
--with-xml2-include=$(brew --prefix libxml2)/include/libxml2
bundle install
from http://www.nokogiri.org/tutorials/installing_nokogiri.html
Try this
sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev
And then install Nokogiri
sudo gem install nokogiri
I did everything in the other answers, but had to do one more thing:
Open Xcode
Click "Agree"
Wait a bit, close Xcode
Rejoice
Seems like this is due to nokogiri 1.6.2.1 specific problem.
I add this inside my Gemfile:
gem 'nokogiri', '~> 1.6', '>= 1.6.7'
And run bundle update nokogiri and then bundle. Everything now working fine.
It may also be an issue with the anaconda version of some of the libs.
$ conda deactivate
$ gem uninstall nokogiri
$ gem install nokogiri
$ conda activate base
worked for me.
I had the similar issue. The reason was outdated xcode.
If you run brew doctor you might see it. Just open AppStore, got to updates tab and update your xcode.
If nothing above works,
Try deleting Gemfile.lock, and do reinstalling of gems.
Spencer's answer worked for me, but I also needed to use the -n parameter to overcome the permission issue documented here.
So in the end, the command that worked for me was:
gem install -n /usr/local/bin nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2 --use-system-libraries
Deleting nokogiri in rbenv gem folder and reinstalling solved it for me.
This helped me fix this
I reinstalled Xcode and directed xcode-select to its path
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
ref:
https://stackoverflow.com/a/17980786/3861525
I had the same issue while updating to xcode 10. I resolved it with the following steps :
xcode-select --install
bundle install --deployment
gem install nokogiri
Github Answer
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
bundle install
I'm installing nokogiri 1.6.6.2 on Arch Linux,as metasploit installation can't proceed without it.
I got the following output:
[ blackarch Downloads ]# gem install ./nokogiri-1.6.6.2.gem
Building native extensions. This could take a while...
ERROR: Error installing ./nokogiri-1.6.6.2.gem:
ERROR: Failed to build gem native extension.
/usr/bin/ruby -r ./siteconf20151103-1360-1u3d2zo.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:
Building Nokogiri with a packaged version of libxml2-2.9.2
with the following patches applied:
- 0001-Revert-Missing-initialization-for-the-catalog-module.patch
- 0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch
Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:
gem install nokogiri -- --use-system-libraries
[--with-xml2-config=/path/to/xml2-config]
[--with-xslt-config=/path/to/xslt-config]
If you are using Bundler, tell it to use the option:
bundle config build.nokogiri --use-system-libraries
bundle install
Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.2.tar.gz into tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.2... OK
Running patch with /root/.gem/ruby/2.2.0/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch...
Running 'patch' for libxml2 2.9.2... ERROR, review '/root/.gem/ruby/2.2.0/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.2/patch.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
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/$(RUBY_BASE_NAME)
--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
/root/.gem/ruby/2.2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:279:in `block in execute': Failed to complete patch task (RuntimeError)
from /root/.gem/ruby/2.2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:271:in `chdir'
from /root/.gem/ruby/2.2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:271:in `execute'
from extconf.rb:311:in `block in patch'
from extconf.rb:308:in `each'
from extconf.rb:308:in `patch'
from /root/.gem/ruby/2.2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:108:in `cook'
from extconf.rb:278:in `block in process_recipe'
from extconf.rb:177:in `tap'
from extconf.rb:177:in `process_recipe'
from extconf.rb:475:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /root/.gem/ruby/2.2.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /root/.gem/ruby/2.2.0/extensions/x86_64-linux/2.2.0/nokogiri-1.6.6.2/gem_make.out
I've tried every possible solution I found, either locally installation or gem install nokogiri doesn't work...
You can try :
bundle config build.nokogiri --use-system-libraries
bundle install
Or you can reseach sth on
nokogiri doc
Try this way:
gem install nokogiri -v 1.6.6.2 -- --use-system-libraries
sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev
gem install nokogiri
did it for me
If you are using macOS Mojave, Xcode 10 on macOS Mojave moves the system headers out of /usr/include and so Nokogiri will fail to build.
Here is a workaround from nokogiri official installing guide
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
You should update your gemfile with the nokogiri gem
gem 'nokogiri', '~> 1.6', '>= 1.6.8'
after updating your Gemfile with the line of code above run:
bundle install
When I install rails in macOS by running
$ sudo gem install rails
I got the following.
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20150702-37637-10z8fhh.rb extconf.rb
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 packaged libraries.
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:
Building Nokogiri with a packaged version of libxml2-2.9.2
with the following patches applied:
- 0001-Revert-Missing-initialization-for-the-catalog-module.patch
- 0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch
Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:
gem install nokogiri -- --use-system-libraries
[--with-xml2-config=/path/to/xml2-config]
[--with-xslt-config=/path/to/xslt-config]
If you are using Bundler, tell it to use the option:
bundle config build.nokogiri --use-system-libraries
bundle install
Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.2.tar.gz into tmp/x86_64-apple-darwin14/ports/libxml2/2.9.2... OK
Running patch with /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch...
Running 'patch' for libxml2 2.9.2... OK
Running patch with /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch...
Running 'patch' for libxml2 2.9.2... OK
Running 'configure' for libxml2 2.9.2... OK
Running 'compile' for libxml2 2.9.2... ERROR, review '/Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-apple-darwin14/ports/libxml2/2.9.2/compile.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
--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
--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
/Library/Ruby/Gems/2.0.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:279:in `block in execute': Failed to complete compile task (RuntimeError)
from /Library/Ruby/Gems/2.0.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:271:in `chdir'
from /Library/Ruby/Gems/2.0.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:271:in `execute'
from /Library/Ruby/Gems/2.0.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:70:in `compile'
from /Library/Ruby/Gems/2.0.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:110:in `cook'
from extconf.rb:278:in `block in process_recipe'
from extconf.rb:177:in `tap'
from extconf.rb:177:in `process_recipe'
from extconf.rb:475:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-14/2.0.0/nokogiri-1.6.6.2/gem_make.out
Building gems with native extensions is always a pain. You need to have several libs or compile tools installed. In case of nokogiri it's libxml. For this reason i would recommend to use rvm for getting started. RVM is not the cleanest tool, when it comes to unix philosophy, but it's a full-stack solution, meaning that it just works out of the box. It will install all the dependencies for you, using the default osx package manager. As a package manager i recommend homebrew.
#install homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
#install rvm into $HOME
brew install gpg
gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
\curl -sSL https://get.rvm.io | bash -s stable
rvm install ruby --latest
gem install rails #no sudo, as ruby is in $HOME
I was using Ruby 1.9.2 for my RoR 3.2.11 project
All worked fine until I had to upgrade to Ruby 1.9.3 because a gem required it.
By the same occasion I tried to make good use of RVM.
Installed ruby 1.9.3
rvm install 1.9.3 -C --with-openssl-dir=$HOME/.rvm/usr
Created .rvmrc
cd ./my_project/
rvm --create --rvmrc 1.9.3#project
Cleaned up my global gemset
rvm gemset empty
cd into my project and run installed gems
bundle
Error log
Installing rmagick (2.13.2)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/joel/.rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for /opt/local/bin/gcc-apple-4.2... yes
checking for Magick-config... yes
Warning: Found more than one ImageMagick installation. This could cause problems at runtime.
/usr/local/ImageMagick/bin/Magick-config reports version 6.7.3 Q16 is installed in
/usr/local/bin/Magick-config reports version 6.7.1 Q16 is installed in /usr/local/Cellar/imagemagick/6.7.1-1
Using 6.7.3 Q16 from .
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/joel/.rvm/rubies/ruby-1.9.3-p429/bin/ruby
/Users/joel/.rvm/rubies/ruby-1.9.3-p429/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/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:931:in `block in have_header'
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
from /Users/joel/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:930:in `have_header'
from extconf.rb:194:in `<main>'
Gem files will remain installed in /Users/joel/.rvm/gems/ruby-1.9.3-p429#creativebank/gems/rmagick-2.13.2 for inspection.
Results logged to /Users/joel/.rvm/gems/ruby-1.9.3-p429#my_project/gems/rmagick-2.13.2/ext/RMagick/gem_make.out
An error occurred while installing rmagick (2.13.2), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.2'` succeeds before bundling.
At first sight, it looks like I have 2 installations of ImageMagick and that I could spare one.
So my first question would be how to uninstall clean ImageMagick version 6.7.1 Q16?
and of course if there is something else I could try to solve this issue.
ADDITIONAL INFO about packages installed
I know that MacPort and Brew don't work well together but I always been worried about removing MacPort in its entirety. Could that be the problem?
port list | grep magick
p5-perlmagick #6.8.6-0 perl/p5-perlmagick
p5.8-perlmagick #6.8.6-0 perl/p5-perlmagick
p5.10-perlmagick #6.8.6-0 perl/p5-perlmagick
p5.12-perlmagick #6.8.6-0 perl/p5-perlmagick
p5.14-perlmagick #6.8.6-0 perl/p5-perlmagick
p5.16-perlmagick #6.8.6-0 perl/p5-perlmagick
php-gmagick #1.1.2RC1 php/php-gmagick
php53-gmagick #1.1.2RC1 php/php-gmagick
php54-gmagick #1.1.2RC1 php/php-gmagick
php55-gmagick #1.1.2RC1 php/php-gmagick
php-imagick #3.1.0RC2 php/php-imagick
php53-imagick #3.1.0RC2 php/php-imagick
php54-imagick #3.1.0RC2 php/php-imagick
php55-imagick #3.1.0RC2 php/php-imagick
php-magickwand #1.0.9-2 php/php-magickwand
php53-magickwand #1.0.9-2 php/php-magickwand
php54-magickwand #1.0.9-2 php/php-magickwand
php55-magickwand #1.0.9-2 php/php-magickwand
php5-gmagick #1.1.2RC1 php/php5-gmagick
php5-imagick #3.0.1 php/php5-imagick
php5-magickwand #1.0.9-2 php/php5-magickwand
rb-rmagick #2.13.2 ruby/rb-rmagick
brew list
faac grc jasper lame libtiff libvpx pkg-config wget xvid
ffmpeg imagemagick jpeg libogg libvorbis little-cms theora x264 yasm
UPDATE
Remove MacPorts
sudo port -f uninstall installed
Uninstalled brew ImageMagick and installed it again with brew
Installed XCode latest version
and ran bundle, I do get a different message, C compiler missing ... argh, what should I do next, I am trying installing gcc with brew, but not sure that I am heading the right direction, please help:
Installing rmagick (2.13.2)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/joel/.rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for /opt/local/bin/gcc-apple-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
--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/joel/.rvm/rubies/ruby-1.9.3-p429/bin/ruby
Gem files will remain installed in /Users/joel/.rvm/gems/ruby-1.9.3-p429#creativebank/gems/rmagick-2.13.2 for inspection.
Results logged to /Users/joel/.rvm/gems/ruby-1.9.3-p429#creativebank/gems/rmagick-2.13.2/ext/RMagick/gem_make.out
An error occurred while installing rmagick (2.13.2), and Bundler cannot continue.
Make sure that `gem install rmagick -v '2.13.2'` succeeds before bundling.
GCC 4.2
which gcc => /usr/bin/gcc
gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
echo $PATH
/bin;/usr/bin;/usr/sbin;/sbin;/usr/local/ImageMagick/bin:/usr/local/heroku/bin:/Applications/Postgres.app/Contents/MacOS/bin:/Users/joel/.rvm/gems/ruby-1.9.3-p429#biowatts/bin:/Users/joel/.rvm/gems/ruby-1.9.3-p429#global/bin:/Users/joel/.rvm/rubies/ruby-1.9.3-p429/bin:/Users/joel/.rvm/bin:/usr/bin;usr/local/ImageMagick/bin:/usr/local/heroku/bin:/Applications/Postgres.app/Contents/MacOS/bin:/usr/local/ImageMagick/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/joel
NEW ERROR MESSAGE:
Installing json (1.8.0)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/joel/.rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb
creating Makefile
make
compiling generator.c
make: /opt/local/bin/gcc-apple-4.2: No such file or directory
make: *** [generator.o] Error 1
Gem files will remain installed in /Users/joel/.rvm/gems/ruby-1.9.3-p429#biowatts/gems/json-1.8.0 for inspection.
Results logged to /Users/joel/.rvm/gems/ruby-1.9.3-p429#biowatts/gems/json-1.8.0/ext/json/ext/generator/gem_make.out
It obviously looking for /opt/local/bin/gcc-apple-4.2 which I deleted recklessly while following these instructions to move from Macportd to homebrew :(
NOW INSTALLING MISSING PACKAGES with homebrew
brew install apple-gcc42
brew install libxml2
Couple things:
Remove MacPorts (you may list all things you installed with them and reinstall those with brew)
Remove imagemagick from homebrew
Install imagemagick again with brew
You're getting this error You have to install development tools first. which (I guess) means you need to install XCode command line tools.
Then bundle install should work!
you need to reinstall your ruby after removing the package manager you used to install it, the easiest way is to:
rvm reinstall 1.9.3-p429
In combination to the 2 first answers
brew uninstall imagemagick
and used http://cactuslab.com/imagemagick/
Then in my .bash_profile I set
PKG_CONFIG_PATH=/opt/ImageMagick/lib/pkgconfig
C_INCLUDE_PATH=/opt/ImageMagick/include/ImageMagick-6
and finally
bundle