【问题标题】:failed gem install rails on mac ERROR: Failed to build gem native extensionmac 上的 gem install rails 失败错误:无法构建 gem 本机扩展
【发布时间】:2013-09-29 06:42:59
【问题描述】:

我下载了 xcode、命令行工具、home brew、rvm 和 ruby​​,但是当我使用命令 sudo gem install rails 时,我收到一条错误消息。不知道该怎么做任何帮助都会很棒,我想在我的新 Mac 上安装 rails。

ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied - /Users/cheatermoves/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.14/test/test_atomic.rb
marshalls-MacBook-Air:~ cheatermoves$ sudo gem install rails
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

    /Users/cheatermoves/.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/cheatermoves/.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/cheatermoves/.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/cheatermoves/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0'
    from /Users/cheatermoves/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:817:in `try_run'
    from extconf.rb:26:in `<main>'

【问题讨论】:

  • gcc --version 的输出是什么?
  • 配置为:--prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM 版本5.0 (clang-500.2.76) (基于 LLVM 3.3svn) 目标:x86_64-apple-darwin12.5.0 线程模型:posix
  • 我遇到了同样的错误...
  • 答案在输出中:您需要安装开发工具。见stackoverflow.com/questions/18216865/…
  • @MarshallLanners 你解决了这个问题吗?你是怎么解决这个问题的?

标签: ruby-on-rails ruby


【解决方案1】:

您可能不想将 sudo 与 RVM 一起使用...尝试一下:

gem install rails

【讨论】:

    【解决方案2】:
    sudo gcc --version 
    

    完成此操作后,请接受 xcode 的用户协议! (这就是为我解决的问题。)

    【讨论】:

      猜你喜欢
      • 2012-08-06
      • 2014-01-28
      • 2019-06-20
      • 2013-06-27
      • 2018-04-26
      • 2012-04-20
      • 2021-01-12
      • 2013-09-22
      • 1970-01-01
      相关资源
      最近更新 更多