-1

My machine using OSX El Capitan. I already follow the instructions one by one. It's working fine until I need to install rails, something unwanted happened. BTW I already installed Xcode command line tools but still not fix even I restart the terminal and machine. I got this error message.

gem install rails -v 4.2.4

Error message

Last login: Sat Nov  7 15:07:53 on ttys000
Mohammads-MacBook-Air% gem install rails -v 4.2.4
Ignoring curb-0.8.8 because its extensions are not built.  Try: gem pristine curb --version 0.8.8
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

    /Users/ZERO/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20151107-786-tg78i0.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.
Ignoring curb-0.8.8 because its extensions are not built.  Try: gem pristine curb --version 0.8.8
-----
The file "/usr/include/iconv.h" is missing in your build environment,
which means you haven't installed Xcode Command Line Tools properly.

To install Command Line Tools, try running `xcode-select --install` on
terminal and follow the instructions.  If it fails, open Xcode.app,
select from the menu "Xcode" - "Open Developer Tool" - "More Developer
Tools" to open the developer site, download the installer for your OS
version and run it.
-----
*** 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/ZERO/.rvm/rubies/ruby-2.2.1/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/ZERO/.rvm/gems/ruby-2.2.1/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Users/ZERO/.rvm/gems/ruby-2.2.1/extensions/x86_64-darwin-14/2.2.0-static/nokogiri-1.6.6.2/gem_make.out
Mohammads-MacBook-Air% 

Reference: https://gorails.com/setup/osx/10.11-el-capitan

Tom Zych
  • 13,329
  • 9
  • 36
  • 53
Nurdin
  • 23,382
  • 43
  • 130
  • 308

3 Answers3

1

There error message tells you:

The file "/usr/include/iconv.h" is missing in your build environment, which means you haven't installed Xcode Command Line Tools properly.

To install Command Line Tools, try running xcode-select --install on terminal and follow the instructions. If it fails, open Xcode.app, select from the menu "Xcode" - "Open Developer Tool" - "More Developer Tools" to open the developer site, download the installer for your OS version and run it.

Unfortunately this error message is sometimes misleading. What the message really tries to tell you is that it just wasn't able to use the Command Line Tools. That does not necessarily mean they are not installed - it might mean that you just did not accept the license agreement yet.

I noticed that this is a common problem after installing Xcode and it recurs after updating to newer versions of Xcode. I recommened to do the follow steps after each installation or upgrade of Xcode:

  • Open Xcode and accept the license agreement
  • Try to reinstall the Command Line Tools

The second step seems to depend on your OS versions. If xcode-select --install does not work try to start the install Command Line Developer Tools app in /System/Library/CoreServices.

After reinstalling the Command Line Tools try to rerun bundle install.

spickermann
  • 100,941
  • 9
  • 101
  • 131
0

It's working now. Using rvm to handel it.

rvm install ruby-2.1.1
rvm 2.1.1
gem install rails -v 4.1.0
Nurdin
  • 23,382
  • 43
  • 130
  • 308
0

Opening Xcode and accepting the license agreement fixed this error for me. Afterwards, could run sudo gem install rails successfully.

noctrnal
  • 191
  • 4