简体   繁体   中英

An error occurred while installing nokogiri (1.10.10), and Bundler cannot continue

  • Os: Ubuntu 18.04
  • ruby: 2.7
  • rails: 6.*

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

 current directory: /home/.rvm/gems/ruby-2.7.0/gems/nokogiri-1.10.10/ext/nokogiri

/home/.rvm/rubies/ruby-2.7.0/bin/ruby -I /home/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0 -r./siteconf20210329-30335-1ed7nme.rb extconf.rb --use-system-libraries 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/.rvm/rubies/ruby-2.7.0/bin/$(RUBY_BASE_NAME) --help --clean /home/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/mkmf.rb:471:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /home/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/mkmf.rb:597:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /home/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/mkmf.rb:597:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /home/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/mkmf.rb:597:in block in try_compile' from /home/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/mkmf.rb:544:in with_werror' from /home/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/mkmf.rb:597:in try_compile' from extconf.rb:138:in nokogiri_try_compile' from extconf.rb:162:in block in add_cflags' from /home/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/mkmf.rb:655:in with_cflags' from extconf.rb:161:in add_cflags' from extconf.rb:416:in `'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/home/.rvm/gems/ruby-2.7.0/extensions/x86_64-linux/2.7.0/nokogiri-1.10.10/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/.rvm/gems/ruby-2.7.0/gems/nokogiri-1.10.10 for inspection. Results logged to /home/.rvm/gems/ruby-2.7.0/extensions/x86_64-linux/2.7.0/nokogiri-1.10.10/gem_make.out

An error occurred while installing nokogiri (1.10.10), and Bundler cannot continue. Make sure that gem install nokogiri -v '1.10.10' --source 'https://rubygems.org/' succeeds before bundling.

First, check your mkmf.log file for more details.

gcc: error: unrecognized command line option '-Wduplicated-cond'
gcc: error: unrecognized command line option '-Wmisleading-indentation'
gcc: error: unrecognized command line option '-Wimplicit-fallthrough=0'

Solution : brew unlink gcc

$ bundle install (will work fine)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM