简体   繁体   English

无法安装Rails extconf.rb失败

[英]Unable to install Rails extconf.rb failed

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. 请注意,我已经安装了最新的Xcode和已安装的命令行工具,我正在使用OSX 10.8.4。 I've installed Ruby 2.0.0 as well. 我也安装了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

我有类似的问题,它通过安装命令行工具得到解决:

xcode-select --install

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.0 and then I typed rvm requirements . 我通过键入rvm uninstall ruby-2.0.0了我之前使用rvm uninstall ruby-2.0.0 ,然后输入了rvm requirements This command found that I needed a few other things, such as gcc46. 这个命令发现我需要一些其他的东西,比如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. 奇怪的是,即使我已经安装了xcode命令行工具,也需要gcc编译器,并且gcc绝对安装在我的系统上。

So, if none of the usual methods are working, give rvm requirements a shot! 因此,如果通常的方法都不起作用,请给出rvm requirements

I guess it's a same problem with this question . 我想这个问题也是同样的问题。

Try sudo ln -s /usr/bin/{llvm-,}gcc-4.2 and gem install rails again. 再次尝试sudo ln -s /usr/bin/{llvm-,}gcc-4.2gem install rails

By the way, you're in your own home directory, you don't have to use sudo . 顺便说一下,你在自己的主目录中,你不必使用sudo

I just ran into this with ruby 2.5.3 and 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'

Took a while to find something that worked, as I already had the command line tools installed, and am using asdf not rvm . 花了一段时间找到rvm东西,因为我已经安装了命令行工具,并且使用的是asdf而不是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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM