【问题标题】:Error while installing Rails on OSX 10.9.2在 OSX 10.9.2 上安装 Rails 时出错
【发布时间】:2014-03-21 18:47:19
【问题描述】:

我正在尝试在我的 Macbook 上安装 Rails,但我没有运气我已经尝试了所有方法

-自制 -RVM -珠宝盒 我在这里读到,通过安装 xcode 然后尝试再次安装 rails 它可能会起作用....它可能适用于除我之外的其他人........这是我得到的错误.....

提前致谢。

    $ sudo gem install rails
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for libkern/OSAtomic.h... *** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/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}/
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:430:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:545:in `block in try_compile'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:498:in `with_werror'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:545:in `try_compile'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:1040:in `block in have_header'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:891:in `block in checking_for'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:336:in `block (2 levels) in postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:306:in `open'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:336:in `block in postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:306:in `open'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:332:in `postpone'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:890:in `checking_for'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:1039:in `have_header'
    from extconf.rb:17:in `<main>'


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/atomic-1.1.16 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/atomic-1.1.16/ext/gem_make.out
$ rails --version
Rails is not currently installed on this system. To get the latest version, simply type:

    $ sudo gem install rails

You can then rerun your "rails" command.
$ 

** 更新**

我成功安装了 xcode 命令行开发人员工具,然后继续尝试安装 rails,它给了我一个像这样的新错误......

$ sudo gem install rails
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for libkern/OSAtomic.h... yes
creating Makefile

make "DESTDIR="
compiling atomic_reference.c
atomic_reference.c:57:59: warning: incompatible pointer types passing 'void **' to parameter of type 'volatile int64_t *' (aka 'volatile long long *') [-Wincompatible-pointer-types]
    if (OSAtomicCompareAndSwap64(expect_value, new_value, &DATA_PTR(self))) {
                                                          ^~~~~~~~~~~~~~~
/usr/include/libkern/OSAtomic.h:507:93: note: passing argument to parameter '__theValue' here
bool    OSAtomicCompareAndSwap64( int64_t __oldValue, int64_t __newValue, volatile int64_t *__theValue );
                                                                                            ^
1 warning generated.
linking shared-object atomic_reference.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [atomic_reference.bundle] Error 1


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/atomic-1.1.16 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/atomic-1.1.16/ext/gem_make.out

【问题讨论】:

标签: ruby-on-rails ruby macos installation


【解决方案1】:

仔细阅读你的输出:

你必须先安装开发工具。

看来您需要安装 OSX 开发工具。在 Mavericks 中执行此操作的最简单方法是运行 xcode-select 以触发安装,如本指南所述:http://www.computersnyou.com/2025/2013/06/install-command-line-tools-in-osx-10-9-mavericks-how-to/

【讨论】:

  • 我也试过了。但我收到一条错误消息,提示“无法安装软件,因为软件更新服务器当前无法使用它”
  • 然后尝试不同的来源。您可以直接从 Apple 的开发者网站获取(如果您使用 Apple ID 登录):developer.apple.com/xcode/downloads
  • 不是我的幸运日......我从苹果开发者网站下载了它,它安装得很好,但是当我执行 sudo gem install rails 时,它又给了我一个错误
  • 如果你使用 rvm (simple) 安装了 ruby​​,那么不要使用 sudo
【解决方案2】:

您好像没有在系统中安装XCode

首先从 Mac Store 安装 XCode(或者只是按照@DavidUnderwood 的建议安装命令行工具) 安装后,转到首选项 -> 下载 -> 安装命令行工具

还在 Rails 指南上找到了一个很好的资源,即 Rails One Click for Mac。

请参阅 Rackspace 的 step by step guide

【讨论】:

  • 现在你不需要完整的 XCode 安装,只需要命令行工具。
【解决方案3】:

我也遇到了同样的问题... google了很多,终于找到了解决办法

尝试在终端中写这个:

sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install rails

这里提出了解决方案 - Trouble installing rails on MAC OS X 10.9.2

【讨论】:

    猜你喜欢
    • 2014-05-02
    • 2015-01-14
    • 1970-01-01
    • 2014-04-29
    • 1970-01-01
    • 2014-05-05
    • 1970-01-01
    • 2015-02-24
    • 1970-01-01
    相关资源
    最近更新 更多