xcode 用于 ruby gems 的新 10.9 OSX 的命令行工具?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17066849/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
command line tools for new 10.9 OSX for ruby gems?
提问by sandric
After installing OSX Mavericks 10.9 demo, Im getting this after running bundle
安装 OSX Mavericks 10.9 演示后,我在运行 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".
我想我没有命令行工具,所以我试着下载了一些。它发现在我的 XCode 中没有通常的链接(它是 4,而不是 5,不知道为什么。如果有安装第五个 xcode 的方法 - 请帮忙)。所以我去了苹果开发者网页,没有找到 10.9 的命令行工具。我尝试了 10.8 - 它打印“尝试安装 10.7”,在尝试使用 10.7 的工具后 - 它打印“尝试安装 10.8”。
Please, help. I'll provide all info for help.
请帮忙。我会提供所有信息寻求帮助。
回答by Daniel Dunbar
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).
在 OS X 10.9 中,命令行开发人员工具现在在使用时按需安装(这是您在后面的评论中提到的弹出窗口)。
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.
第一次尝试使用其中一个命令行工具时,将显示弹出窗口,原始命令将返回一条消息,提示需要安装命令行工具和错误代码。在这种情况下,问题在于 ruby 进程隐藏了有关所需命令行工具的消息。
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.
如果您希望显式安装命令行工具(而不是等待弹出窗口被触发),您可以运行xcode-select --install
. 命令行工具包也可从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.
请注意,如果您的系统上安装了 Xcode,您将不再需要单独的命令行工具包,/usr/bin 中的工具将自动使用位于 Xcode 应用程序内部的工具。这就是 Xcode UI 不再提供为您安装命令行工具的选项的原因。
回答by Ian Ehlert
For others running into this problem, I had to also install apple-gcc via brew to get it to work:
对于遇到此问题的其他人,我还必须通过 brew 安装 apple-gcc 才能使其正常工作:
brew install apple-gcc42
brew install apple-gcc42
回答by biobonnie
I had this same problem installing gems after upgrading to OSX Mavericks. I saw this among the error messages:
升级到 OSX Mavericks 后,我在安装 gems 时遇到了同样的问题。我在错误消息中看到了这一点:
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:
这表明它在找到 gcc 时遇到了麻烦。当我输入“ls /usr/bin”时,我看到我有“gcc”而不是“gcc-4.2”。所以我设置了一个符号链接来告诉它在“gcc”而不是“gcc-4.2”中查找,如下所示:
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
This fixed my problem. Hope it helps.
这解决了我的问题。希望能帮助到你。
回答by Stanley
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
我必须同时运行xcode-select --install
并sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
安装 bundleffi
回答by Chunsaker
I don't have enough reputation to comment, but Vyke's solution was helpful/required for me. My path to success after updating to mavericks was the following:
我没有足够的声誉来发表评论,但 Vyke 的解决方案对我很有帮助/需要。更新到小牛队后,我的成功之路如下:
- Install xcode from the appstore (terminal couldn't find it find it on the server)
- Open xcode and accept the terms
- Use biobonnie's solution to move the GCC file
- rvm system
- rvm get head
- gem install yourgemname (in my case json)
- bundle install
- gem update rake
- 从appstore安装xcode(终端在服务器上找不到)
- 打开xcode并接受条款
- 使用biobonnie的解决方案移动GCC文件
- 房车系统
- rvm 得到头
- gem install yourgemname(在我的例子中是json)
- 捆绑安装
- 宝石更新耙
... and then I could get back to updating our jekyll/octopress based website.
...然后我可以回去更新我们基于 jekyll/octopress 的网站。
回答by mc01
XCode 5.0.2 on Mavericks gave me the same error. Seems it wasn't fixed in 5.0.1 as expected.
Mavericks 上的 XCode 5.0.2 给了我同样的错误。似乎它没有像预期的那样在 5.0.1 中修复。
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?
尝试xcode-select -- install
打开一个对话框来安装命令行工具(我已经做过两次),但失败了,因为它们“在服务器上找不到”。也许这种方法已经过时了?
biobonnie's solution above worked for me:
上面 biobonnie 的解决方案对我有用:
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
After that, cocoapods finally install properly! Thanks! (Would upvote, but can't yet ... )
之后,cocoapods 终于正确安装了!谢谢!(会赞成,但还不能……)
回答by Coderama
I just upgraded mountain lion to mavericks and received the above message.
刚刚将山狮升级为小牛,收到了上述消息。
I ended up launching XCode and it asked to install components automatically. After that was completed I re-bundled and it worked.
我最终启动了 XCode,它要求自动安装组件。完成后,我重新捆绑并且它起作用了。
回答by Vyke
If you're using Ruby version manager (rvm) the following worked for me.
如果您使用的是 Ruby 版本管理器 (rvm),以下内容对我有用。
Before you run the following, be sure to verify the symbolic link in /Users/yourusername/.rvm/rubies/. Mine looks like this...
在运行以下命令之前,请务必验证 /Users/yourusername/.rvm/rubies/ 中的符号链接。我的看起来像这样...
default -> /Users/yourusername/.rvm/rubies/ruby-1.9.3-p429
If your sym link isn't set correctly, you can set it using...
如果您的符号链接设置不正确,您可以使用...
cd /Users/yourusername/.rvm/rubies/
ln -s /Users/yourusername/.rvm/rubies/ruby-1.9.3-p429 default
Then run the following from the command line
然后从命令行运行以下命令
rvm system
rvm gemset export system.gems
rvm 1.9.3 #use your Ruby version here
rvm gemset import system.gems
now you should be ready to install your gems
现在你应该准备好安装你的 gems
gem install yourgemname