command line tools for new 10.9 OSX for ruby gems?

18,461

Solution 1

TLDR:

xcode-select --install

In OS X 10.9, the command line developer tools are now installed on demand when they are used (this is the popup you mention seeing in a later comment).

The first time something tries to use one of the command line tools, the popup will be presented and the original command will return with a message that the command line tools need to be installed and with an error code. In this case, the problem is that the ruby process is hiding the message about the command line tools being needed.

If you wish to explicitly install the command line tools (instead of waiting for the popup to be triggered), you can run xcode-select --install. The command line tools package is also available as an independent download from http://developer.apple.com/downloads.

Note that if you have Xcode installed on your system, you should no longer need the separate command line tools package, the tools in /usr/bin will automatically use the ones located inside of the Xcode application. This is why the Xcode UI no longer offers the option to install the command line tools for you.

Solution 2

For others running into this problem, I had to also install apple-gcc via brew to get it to work:

brew install apple-gcc42

Solution 3

I had this same problem installing gems after upgrading to OSX Mavericks. I saw this among the error messages:

make: gcc-4.2: No such file or directory

Which suggested that it's having trouble finding gcc. When I type "ls /usr/bin", I see that I have "gcc" but not "gcc-4.2". So I set up a symlink to tell it to look in "gcc" instead of "gcc-4.2", like so:

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

This fixed my problem. Hope it helps.

Solution 4

I had to run both xcode-select --install and sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2 to get bundle to install ffi

Solution 5

XCode 5.0.2 on Mavericks gave me the same error. Seems it wasn't fixed in 5.0.1 as expected.

Trying xcode-select -- install brought up a dialog to install command line tools (which I'd already done twice), but failed because they "weren't found on the server". Maybe this approach is outdated?

biobonnie's solution above worked for me:

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2 

After that, cocoapods finally install properly! Thanks! (Would upvote, but can't yet ... )

Share:
18,461
sandric
Author by

sandric

Worked or tried pretty much everything. More info on github page (examples of Objective C, Swift, Java for android, clojurescript, RoR and ruby. There's even some elisp)

Updated on June 01, 2022

Comments

  • sandric
    sandric almost 2 years

    After installing OSX Mavericks 10.9 demo, Im getting this after running bundle

        Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
    
        /Users/sandric/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb 
    extconf.rb:17: Use RbConfig instead of obsolete and deprecated Config.
    checking for socket() in -lsocket... *** 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/sandric/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
        --with-iconv-dir
        --without-iconv-dir
        --with-iconv-include
        --without-iconv-include=${iconv-dir}/include
        --with-iconv-lib
        --without-iconv-lib=${iconv-dir}/lib
        --with-zlib-dir
        --without-zlib-dir
        --with-zlib-include
        --without-zlib-include=${zlib-dir}/include
        --with-zlib-lib
        --without-zlib-lib=${zlib-dir}/lib
        --with-socketlib
        --without-socketlib
    /Users/sandric/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
    You have to install development tools first.
        from /Users/sandric/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
        from /Users/sandric/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
        from /Users/sandric/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:619:in `try_func'
        from /Users/sandric/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:845:in `block in have_library'
        from /Users/sandric/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
        from /Users/sandric/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
        from /Users/sandric/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from /Users/sandric/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
        from /Users/sandric/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from /Users/sandric/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
        from /Users/sandric/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
        from /Users/sandric/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:840:in `have_library'
        from extconf.rb:27:in `<main>'
    
    
    Gem files will remain installed in /Users/sandric/.bundler/tmp/5282/gems/libxml-ruby-2.6.0 for inspection.
    Results logged to /Users/sandric/.bundler/tmp/5282/gems/libxml-ruby-2.6.0/ext/libxml/gem_make.out
    An error occurred while installing libxml-ruby (2.6.0), and Bundler cannot continue.
    Make sure that `gem install libxml-ruby -v '2.6.0'` succeeds before bundling.
    

    I think that I do not have command line tools, so I tried to download some. It found out that there is no usual link for this in my XCode (it is 4, not 5, dont know why. If there is some way of installing fifth xcode - please help). So I went to apple developers webpage and not found command line tools for 10.9. I tried for 10.8 - it prints "Try install for 10.7", after trying with tools for 10.7 - it prints "try for 10.8".

    Please, help. I'll provide all info for help.

  • sandric
    sandric almost 11 years
    I didnt understant your point and how this corresponds with theme of topic, sorry(
  • Vyke
    Vyke almost 11 years
    Your issue is a gem extension build error. This response was intended to help you reset your ruby version and gemset which should resolve your issue.
  • nschum
    nschum almost 11 years
    Even if you have Xcode installed, it needs to be Xcode 5 and xcode-select needs to point to that specific Xcode. That fixed it for me.
  • Fritzz
    Fritzz over 10 years
    I think I need to point to that specific Xcode too... But how do I do that?
  • Allan Wintersieck
    Allan Wintersieck over 10 years
    For me, it didn't work after only running "xcode-select --install", but did work after doing both that and starting Xcode and following the prompts there as well.
  • JGrubb
    JGrubb over 10 years
    This is also what worked for me. Does anyone have any idea why this is required of (seemingly) only some of us?
  • Wes
    Wes over 10 years
    This is what did it for me with xcode 5.0.2 already installed.
  • Pierre
    Pierre over 9 years
    You put an end to 3 hours of pain (banging my head against a wall). Thank you.