I installed, and reinstalled, Nokogiri multiple times, with and without sudo, and when running bundle install I get in my console:
Fetching nokogiri 1.10.7
Installing nokogiri 1.10.7 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/april/.rvm/gems/ruby-2.5.0/gems/nokogiri-1.10.7/ext/nokogiri
/home/april/.rvm/rubies/ruby-2.5.0/bin/ruby -I /home/april/.rvm/rubies/ruby-2.5.0/lib/ruby/site_ruby/2.5.0 -r
./siteconf20200331-50466-133fhom.rb extconf.rb
checking if the C compiler accepts ... *** 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/april/.rvm/rubies/ruby-2.5.0/bin/$(RUBY_BASE_NAME)
--help
--clean
/home/april/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to generate an
executable file. (RuntimeError)
You have to install development tools first.
from /home/april/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:574:in `block in try_compile'
from /home/april/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:521:in `with_werror'
from /home/april/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:574:in `try_compile'
from extconf.rb:138:in `nokogiri_try_compile'
from extconf.rb:162:in `block in add_cflags'
from /home/april/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/mkmf.rb:632:in `with_cflags'
from extconf.rb:161:in `add_cflags'
from extconf.rb:416:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/april/.rvm/gems/ruby-2.5.0/extensions/x86_64-linux/2.5.0/nokogiri-1.10.7/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/april/.rvm/gems/ruby-2.5.0/gems/nokogiri-1.10.7 for inspection.
Results logged to /home/april/.rvm/gems/ruby-2.5.0/extensions/x86_64-linux/2.5.0/nokogiri-1.10.7/gem_make.out
An error occurred while installing nokogiri (1.10.7), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.10.7'` succeeds before bundling.
In Gemfile:
activeadmin_addons was resolved to 1.6.0, which depends on
xdan-datetimepicker-rails was resolved to 2.5.4, which depends on
rails was resolved to 5.1.5, which depends on
actioncable was resolved to 5.1.5, which depends on
actionpack was resolved to 5.1.5, which depends on
actionview was resolved to 5.1.5, which depends on
rails-dom-testing was resolved to 2.0.3, which depends on
nokogiri
I also tried re-installing libxml2 and libxslt and I still keep running into this issue.
Related
This happened to me several times while trying to install Discourse:
Cannot install rbtrace with native extensions.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
*** 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/setoelka/.rbenv/versions/2.7.3/bin/$(RUBY_BASE_NAME)
extconf.rb:6:in `sys': make install failed, please report to https://github.com/tmm1/rbtrace/issues (RuntimeError)
from extconf.rb:43:in `block (2 levels) in <main>'
from extconf.rb:34:in `chdir'
from extconf.rb:34:in `block in <main>'
from extconf.rb:30:in `chdir'
from extconf.rb:30:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/setoelka/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/extensions/arm64-darwin-21/2.7.0/rbtrace-0.4.14/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/setoelka/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rbtrace-0.4.14 for inspection.
Results logged to /Users/setoelka/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/extensions/arm64-darwin-21/2.7.0/rbtrace-0.4.14/gem_make.out
An error occurred while installing rbtrace (0.4.14), and Bundler cannot continue.
Make sure that `gem install rbtrace -v '0.4.14' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
rbtrace
Does anyone know about the problem? I tried running:
gem install rbtrace -v '0.4.14' --source 'http://rubygems.org/' -- --with-cflags=-Wno-implicit-function-declaration
No luck so far.
I solved this problem by myself by looking at the mkmf.log content.
TLDR;
Use the selected Xcode with standar naming, i.e, Xcode.app.
It turned out that Ruby will compile the gem using the compiler from the default Xcode. I have multiple version of Xcodes and use the xcode-select to switch between them.
The thing is, the ruby setup will always looking for the default Xcode.app naming. If you name your selected Xcode something else, you'll get this error.
Ruby version 2.2.4p230
RubyGem version 2.7.2
Ruby-devel and lib64ffi-devel installed.
64-bit OpenMandriva 3.0, urpmi and rpmdrake used.
Goal: to install compass, but the gem ffi is needed first.
I have scoured the internet so hard for the last two days and I'm so stumped... It's impossible for me to install an earlier version of ruby because of the dependency for an older ncurses. I feel like replacing ncurses would open a can of nasty worms.
However... I am also completely open to a compass alternative, where the config.rb project files could be somehow ported / copied so both compass and this other sass compiler could operate. (this is for work and we're not changing the sass builder any time soon).
/usr/share/gems/gems/ffi-1.9.18/ext/ffi_c totally exists, there is an ffi.c file in that directory but can't find any ffi.h file in the vicinity. In a moment of desperation I touched ffi.h in that dir and when I ran gem install it removed it. ;) I would try taking a copy of someone else's libs to see if that works.
Basically any way to get this working without breaking the rest of my packages. I don't use ruby for anything else, just compass.
Here is the output:
# sudo gem install ffi
Building native extensions. This could take a while...
ERROR: Error installing ffi:
ERROR: Failed to build gem native extension.
current directory: /usr/share/gems/gems/ffi-1.9.18/ext/ffi_c
/usr/bin/ruby -r ./siteconf20171110-17988-1lodsok.rb 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
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib64
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/$(RUBY_BASE_NAME)
--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}/lib64
--with-libffi-config
--without-libffi-config
--with-pkg-config
--without-pkg-config
/usr/share/ruby/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/share/ruby/mkmf.rb:587:in `try_cpp'
from /usr/share/ruby/mkmf.rb:1060:in `block in have_header'
from /usr/share/ruby/mkmf.rb:911:in `block in checking_for'
from /usr/share/ruby/mkmf.rb:351:in `block (2 levels) in postpone'
from /usr/share/ruby/mkmf.rb:321:in `open'
from /usr/share/ruby/mkmf.rb:351:in `block in postpone'
from /usr/share/ruby/mkmf.rb:321:in `open'
from /usr/share/ruby/mkmf.rb:347:in `postpone'
from /usr/share/ruby/mkmf.rb:910:in `checking_for'
from /usr/share/ruby/mkmf.rb:1059:in `have_header'
from extconf.rb:16:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/usr/lib64/gems/ruby/ffi-1.9.18/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /usr/share/gems/gems/ffi-1.9.18 for inspection.
Results logged to /usr/lib64/gems/ruby/ffi-1.9.18/gem_make.out
Any help appreciated!
Your error message shows:
/usr/share/ruby/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
And that's how you can solve it:
xcode-select --install
(but make sure beforehand that xcode-select -p is returning the path to a stable Xcode version, like Xcode 10)
See also https://github.com/ffi/ffi/issues/647.
I am trying to run a Rails app through Docker that is using Rails 3.2.11. The gem nokogiri is not being installed when I run bundle install.
I have this in my Gemfile:
gem 'nokogiri', '~> 1.6.8.rc2'
And this in my LOCK file:
nokogiri (1.6.8.rc2)
mini_portile2 (~> 2.1.0)
When I try running bundle install through docker, I get the following error messages:
************************************************************************
Extracting libxml2-2.9.3.tar.gz into tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.3... OK
Running 'configure' for libxml2 2.9.3... OK
Running 'compile' for libxml2 2.9.3... ERROR, review
'/var/www/docker_example/activemodel/ruby/1.9.1/gems/nokogiri-1.6.8.rc2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.3/compile.log'
to see what happened. Last lines are:
========================================================================
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/bash
/var/www/docker_example/activemodel/ruby/1.9.1/gems/nokogiri-1.6.8.rc2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.3/libxml2-2.9.3/missing
aclocal-1.15 -I m4
/var/www/docker_example/activemodel/ruby/1.9.1/gems/nokogiri-1.6.8.rc2/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.3/libxml2-2.9.3/missing:
line 81: aclocal-1.15: command not found
WARNING: 'aclocal-1.15' is missing on your system.
You should only need it if you modified 'acinclude.m4' or
'configure.ac' or m4 files included by 'configure.ac'.
The 'aclocal' program is part of the GNU Automake package:
<http://www.gnu.org/software/automake>
It also requires GNU Autoconf, GNU m4 and Perl in order to run:
<http://www.gnu.org/software/autoconf>
<http://www.gnu.org/software/m4/>
<http://www.perl.org/>
make: *** [aclocal.m4] Error 127
========================================================================
*** 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/ruby1.9.1
--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
/var/www/docker_example/activemodel/ruby/1.9.1/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:366:in `block
in execute': Failed to complete compile task (RuntimeError)
from /var/www/docker_example/activemodel/ruby/1.9.1/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:337:in
`chdir'
from /var/www/docker_example/activemodel/ruby/1.9.1/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:337:in
`execute'
from /var/www/docker_example/activemodel/ruby/1.9.1/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:111:in
`compile'
from /var/www/docker_example/activemodel/ruby/1.9.1/gems/mini_portile2-2.1.0/lib/mini_portile2/mini_portile.rb:150:in
`cook'
from extconf.rb:288:in `block (2 levels) in process_recipe'
from extconf.rb:181:in `block in chdir_for_build'
from extconf.rb:180:in `chdir'
from extconf.rb:180:in `chdir_for_build'
from extconf.rb:287:in `block in process_recipe'
from extconf.rb:186:in `tap'
from extconf.rb:186:in `process_recipe'
from extconf.rb:477:in `<main>'
Gem files will remain installed in /var/www/docker_example/activemodel/ruby/1.9.1/gems/nokogiri-1.6.8.rc2 for
inspection.
Results logged to /var/www/docker_example/activemodel/ruby/1.9.1/gems/nokogiri-1.6.8.rc2/ext/nokogiri/gem_make.out
An error occurred while installing nokogiri (1.6.8.rc2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.8.rc2'` succeeds before bundling.
In Gemfile:
fog was resolved to 1.23.0, which depends on
nokogiri
I've tried modifying the Gem File a few times but it keeps resulting in Nokogiri not being installed properly.
Any help is greatly appreciated!
Make sure libxml2 is installed on your machine. Is it available to install with brew install or apt-get install depending on your OS.
Update: also if you're trying to run your app inside of docker container add libxml2 too and install nokogiri with RUN gem install nokogiri -v '1.6.8.1' in your Dockerfile
While trying to do "bundle install", I receive error message below
environment = OSX 10.9.4, rbenv 0.4.0,
ruby 2.1.2,
Homebrew 0.9.5
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/hirotakagotanda/.rbenv/versions/2.1.2/bin/ruby extconf.rb
*** 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/hirotakagotanda/.rbenv/versions/2.1.2/bin/ruby
/Users/hirotakagotanda/.rbenv/versions/2.1.2/lib/ruby/2.1.0/fileutils.rb:1573:in `stat': No such file or directory # rb_file_s_stat - ./212/ruby_debug.h (Errno::ENOENT)
from /Users/hirotakagotanda/.rbenv/versions/2.1.2/lib/ruby/2.1.0/fileutils.rb:1573:in `block in fu_each_src_dest'
from /Users/hirotakagotanda/.rbenv/versions/2.1.2/lib/ruby/2.1.0/fileutils.rb:1587:in `fu_each_src_dest0'
from /Users/hirotakagotanda/.rbenv/versions/2.1.2/lib/ruby/2.1.0/fileutils.rb:1571:in `fu_each_src_dest'
from /Users/hirotakagotanda/.rbenv/versions/2.1.2/lib/ruby/2.1.0/fileutils.rb:399:in `cp'
from extconf.rb:83:in `block in <main>'
from extconf.rb:82:in `each'
from extconf.rb:82:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/hirotakagotanda/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/debugger-1.6.6 for inspection.
Results logged to /Users/hirotakagotanda/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/debugger-1.6.6/gem_make.out
An error occurred while installing debugger (1.6.6), and Bundler cannot continue.
Make sure that `gem install debugger -v '1.6.6'` succeeds before bundling.
Could anyone please provide me solution, I have been misfortunate to find out any...
This is likely a problem with the Xcode Command Line Tools. There are a number of steps needed to get this right.
This question Installing Ruby Debug IDE Gem provides one example.
I ran into the same issue and solved it by agreeing to xcode's license (it seems to happen after an update and you haven't yet agreed to the update)
Just run xcodebuild -license from the command line
Found the answer thanks to this question
Neither of the above comments helped me. Changing to ruby 2.1.1 of below allowed me to bundle without issue.
rbenv local 2.1.1
bundle install
using ruby 2.1.2, it breaks in the same place
I am a Windows 8 user. I installed lib v8 with:
gem install libv8 -v '3.16.14.3' -- --with-system-v8
Now I am facing trouble with installing therubyracer. Following is the error:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe extconf.rb
checking for main() in -lpthread... yes
checking for v8.h... no
*** 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}/
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby
--with-pthreadlib
--without-pthreadlib
--enable-debug
--disable-debug
--with-v8-dir
--without-v8-dir
--with-v8-include
--without-v8-include=${v8-dir}/include
--with-v8-lib
--without-v8-lib=${v8-dir}/
/usr/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/libv8/location.rb:50:in `configure': You have chosen to use the version of V8 found on your system (Libv8::Location::System::NotFoundError)
and *not* the one that is bundle with the libv8 rubygem. However,
it could not be located. please make sure you have a version of
v8 that is compatible with 3.16.14.3 installed. You may
need to special --with-v8-dir options if it is in a non-standard
location
thanks,
The Mgmt
from /usr/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/lib/libv8.rb:7:in `configure_makefile'
from extconf.rb:32:in `<main>'
Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/therubyracer-0.12.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.9.1/gems/therubyracer-0.12.1/ext/v8/gem_make.out
An error occurred while installing therubyracer (0.12.1), and Bundler cannot
continue.
Make sure that `gem install therubyracer -v '0.12.1'` succeeds before bundling.
I tried following other stackoverflow links but nothing seem to help
Because therubyracer-0.12.1 relys on libv8-3.16.14.7, you install libv8-3.16.14.3 rather than libv8-3.16.14.7 firstly, so there is a conflict.
It works for me:
$ gem uninstall libv8
$ gem install therubyracer -v '0.12.1'
$ gem install libv8 -v '3.16.14.3' -- --with-system-v8