用于新的10.9 OSX for ruby​​ gems的命令行工具?

san*_*ric 40 ruby macos xcode command-line-tool

安装OSX Mavericks 10.9演示后,我在运行捆绑后得到这个

    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.
Run Code Online (Sandbox Code Playgroud)

我认为我没有命令行工具,所以我试着下载一些.它发现在我的XCode中没有通常的链接(它是4,而不是5,不知道为什么.如果有一些方法安装第五个xcode - 请帮助).所以我去了苹果开发者网页,没有找到10.9的命令行工具.我尝试了10.8 - 在尝试使用10.7的工具后打印"试用10.7安装" - 它打印"试试10.8".

请帮忙.我会提供所有帮助信息.

Dan*_*bar 99

TLDR:

xcode-select --install
Run Code Online (Sandbox Code Playgroud)

在OS X 10.9中,命令行开发人员工具现在在使用时按需安装(这是您在稍后的注释中提到的弹出窗口).

第一次尝试使用其中一个命令行工具时,将显示弹出窗口,原始命令将返回,并显示需要安装命令行工具并带有错误代码的消息.在这种情况下,问题是ruby进程隐藏了有关所需命令行工具的消息.

如果您希望显式安装命令行工具(而不是等待触发弹出窗口),则可以运行xcode-select --install.命令行工具包也可以从http://developer.apple.com/downloads独立下载.

请注意,如果您的系统上安装了Xcode,则不再需要单独的命令行工具包,/ usr/bin中的工具将自动使用位于Xcode应用程序内部的工具.这就是为什么Xcode UI不再提供为您安装命令行工具的选项.

  • 即使你安装了Xcode,它也需要是Xcode*5*,xcode-select需要指向特定的Xcode.这为我解决了这个问题. (2认同)
  • 我想我也需要指出那个特定的Xcode ......但是我该怎么做呢? (2认同)

小智 15

对于遇到此问题的其他人,我还必须通过brew安装apple-gcc才能使其工作:

brew install apple-gcc42


小智 8

升级到OSX Mavericks后,我遇到了同样的问题.我在错误消息中看到了这个:

make: gcc-4.2: No such file or directory
Run Code Online (Sandbox Code Playgroud)

这表明它在找到gcc时遇到了麻烦.当我输入"ls/usr/bin"时,我看到我有"gcc"而不是"gcc-4.2".所以我设置了一个符号链接,告诉它查看"gcc"而不是"gcc-4.2",如下所示:

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
Run Code Online (Sandbox Code Playgroud)

这解决了我的问题.希望能帮助到你.


小智 5

我必须运行两个xcode-select --installsudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2获得捆绑安装ffi