Ruby-on-rails 无法安装 Rails extconf.rb 失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18094564/
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
Unable to install Rails extconf.rb failed
提问by Willie Tran
I'm new to Ruby on Rails, and I'm getting the below error when I'm installing it.
我是 Ruby on Rails 的新手,安装时出现以下错误。
Please note, I have installed the latest Xcode and installed command line tools, and I'm using OSX 10.8.4. I've installed Ruby 2.0.0 as well.
请注意,我已经安装了最新的 Xcode 并安装了命令行工具,并且我使用的是 OSX 10.8.4。我也安装了 Ruby 2.0.0。
-bash-3.2$ sudo gem install rails
Password:
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
*** 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/WillieTran/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
--with-atomic_reference-dir
--without-atomic_reference-dir
--with-atomic_reference-include
--without-atomic_reference-include=${atomic_reference-dir}/include
--with-atomic_reference-lib
--without-atomic_reference-lib=${atomic_reference-dir}/
/Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0'
from /Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:817:in `try_run'
from extconf.rb:24:in `<main>'
Gem files will remain installed in /Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/atomic-1.1.12 for inspection.
Results logged to /Users/WillieTran/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/atomic-1.1.12/ext/gem_make.out
回答by Hua2308
I had similar problem and it gets solved by installing command line tools:
我有类似的问题,它通过安装命令行工具得到解决:
xcode-select --install
回答by Danny
The symlinking did not solve the problem for me. I uninstalled my ruby that I previously had installed using rvm by typing rvm uninstall ruby-2.0.0and then I typed rvm requirements. This command found that I needed a few other things, such as gcc46. It's strange that the gcc compiler was needed, even though I had installed the xcode command line tools, and gcc was most definitely installed on my system.
符号链接并没有为我解决问题。我通过键入卸载了我之前使用 rvm 安装的 ruby,rvm uninstall ruby-2.0.0然后键入了rvm requirements. 这个命令发现我还需要一些其他的东西,比如gcc46。奇怪的是需要 gcc 编译器,即使我已经安装了 xcode 命令行工具,而且 gcc 绝对安装在我的系统上。
So, if none of the usual methods are working, give rvm requirementsa shot!
因此,如果通常的方法都不起作用,请rvm requirements试一试!
回答by scorix
I guess it's a same problem with this question.
我想这个问题也有同样的问题。
Try sudo ln -s /usr/bin/{llvm-,}gcc-4.2and gem install railsagain.
尝试sudo ln -s /usr/bin/{llvm-,}gcc-4.2和gem install rails试。
By the way, you're in your own home directory, you don't have to use sudo.
顺便说一句,你在你自己的主目录中,你不必使用sudo.
回答by brendanwb
I just ran into this with ruby 2.5.3and was able to install cairo by calling:
我刚刚遇到了这个问题,ruby 2.5.3并且能够通过调用来安装 cairo:
PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig gem install cairo -v '1.15.2'
PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig gem install cairo -v '1.15.2'
Took a while to find something that worked, as I already had the command line tools installed, and am using asdfnot rvm.
花了一段时间才找到有用的东西,因为我已经安装了命令行工具,并且正在使用asdfnot rvm。
Thanks to this thread for helping with the fix: https://github.com/ruby-gnome2/ruby-gnome2/issues/259#issuecomment-59751807
感谢此线程帮助修复:https: //github.com/ruby-gnome2/ruby-gnome2/issues/259#issuecomment-59751807

