extconf failed, exit code 1 error when installing [Ruby on Rails] 5 on OS X Yosemite 10.10.5
Asked Answered
U

4

6

I'm trying to install Ruby on Rails v5 on OS X Yosemite 10.10.5, following the instructions on the rails site:

http://railsapps.github.io/installrubyonrails-mac.html

When I run this:

sudo gem install rails --version 5.0.0 --no-ri --no-rdoc

I get the error ERROR: Failed to build gem native extension. Here are parts of the output on my command line that might be useful:

current directory: /Users/me/.rvm/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri

[...]


Running 'compile' for libxml2 2.9.4... ERROR, review '/Users/me/.rvm/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri/tmp/x86_64-apple-da

rwin14.5.0/ports/libxml2/2.9.4/compile.log' to see what happened. Last lines are:

[...]

 1 error generated.
    make[2]: *** [xmlIO.lo] Error 1
    make[1]: *** [all-recursive] Error 1
    make: *** [all] Error 2
    ========================================================================
    *** 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.

[...]

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

      /Users/me/.rvm/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-14/2.3.0/nokogiri-1.6.8/mkmf.log


    extconf failed, exit code 1

And here's part of the mkmf.log file:

"gcc -o conftest -I/Users/me/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/x86_64-darwin14 -I/Users/me/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/ruby/backward -I/Users/me/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0 -I.  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -fno-common -pipe  conftest.c  -L. -L/Users/thanos/.rvm/rubies/ruby-2.3.0/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib     -lruby.2.3.0  -lpthread -ldl -lobjc  "
/Users/me/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/mkmf.rb:395: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

I have no idea what is going on :(. Can someone help?

RUBY VERSION: 2.3.0p0. RUBYGEMS VERSION: 2.5.1

xcode-select is successfully installed.

Thanks!

Ultramontane answered 11/7, 2016 at 14:14 Comment(2)
when you run gem env, what version of rubygems do you have? Also, have you accepted the xcode license (sudo xcodebuild -license)?Homemade
RUBYGEMS VERSION: 2.5.1. I've accepted the license but I still get the same error. Thanks.Ultramontane
U
0

I solved it. The error had to do with nokogiri. I installed it separately with the -- --use-system-libraries parameter:

gem install nokogiri -- --use-system-libraries

and I managed afterwards to install rails without errors.

Ultramontane answered 12/7, 2016 at 11:31 Comment(2)
Thanks for the answer. However, I get invalid option: --use-system-libraries -- maybe you wanna update it ?Underclothes
gem install nokogiri -- --use-system-libraries doc: nokogiri.org/tutorials/…Quartering
H
8

http://www.nokogiri.org/tutorials/installing_nokogiri.html says they recommend installing with included libraries, not installing with system libraries.

So I tried (on Ubuntu) following the instruction there, and it worked

sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev
gem install nokogiri
Hyaloid answered 22/5, 2018 at 18:35 Comment(1)
I had an error when executing 'sudo gem install sass'. Your answer solved the problem.Dressing
S
1

Try updating gems:

gem update --system

Seaborne answered 15/1, 2022 at 0:44 Comment(0)
U
0

I solved it. The error had to do with nokogiri. I installed it separately with the -- --use-system-libraries parameter:

gem install nokogiri -- --use-system-libraries

and I managed afterwards to install rails without errors.

Ultramontane answered 12/7, 2016 at 11:31 Comment(2)
Thanks for the answer. However, I get invalid option: --use-system-libraries -- maybe you wanna update it ?Underclothes
gem install nokogiri -- --use-system-libraries doc: nokogiri.org/tutorials/…Quartering
W
0

I installed a newer version of rbenv (and ruby), use whatever version you'd like

RUBY_CONFIGURE_OPTS=--with-readline-dir="$(brew --prefix readline)" rbenv install 2.4.0

I updated my gems

gem update --system

and then was able to install rails without this nokogiri error

gem install rails
Weevily answered 30/1, 2019 at 17:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.