-2

ERROR: Error installing rails: ERROR: Failed to build gem native extension.

current directory: /Library/Ruby/Gems/2.3.0/gems/nokogiri-1.10.1/ext/nokogiri

/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -I /Library/Ruby/Site/2.3.0 -r ./siteconf20190304-9093-ehjkih.rb extconf.rb checking if the C compiler accepts -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2... * 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.3/usr/bin/$(RUBY_BASE_NAME) --help --clean /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:456:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:571:inblock in try_compile' from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:522:in with_werror' from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:571:intry_compile' from extconf.rb:138:in nokogiri_try_compile' from extconf.rb:162:inblock in add_cflags' from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:629:in with_cflags' from extconf.rb:161:inadd_cflags' from extconf.rb:416:in `'

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

/Library/Ruby/Gems/2.3.0/extensions/universal-darwin-16/2.3.0/nokogiri-1.10.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/nokogiri-1.10.1 for inspection. Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-16/2.3.0/nokogiri-1.10.1/gem_make.out

1 Answers1

0

first, run this command

sudo apt-get -f install

then, run this command

sudo apt-get install ruby-dev zlib1g-dev liblzma-dev

this will install dependencies. gem native extension successfully build.

Vishal
  • 818
  • 8
  • 20