【问题标题】:Install any version of ruby with RVM on mavericks在 Mavericks 上使用 RVM 安装任何版本的 ruby
【发布时间】:2013-10-25 16:11:39
【问题描述】:

我刚刚升级到 osx mavericks,我想安装 ruby​​ 2.0,但我收到了 configure: error: cannot run C compiled programs. 错误。

我用rvm get stable 更新rvm,然后输入rvm install 2.0.0 并得到一个错误,将我引导到一个日志文件。日志文件包含:

configure: WARNING: unrecognized options: --without-tcl, --without-tk
checking build system type... x86_64-apple-darwin13.0.0
checking host system type... x86_64-apple-darwin13.0.0
checking target system type... x86_64-apple-darwin13.0.0
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/Users/mattroberts/.rvm/src/ruby-2.0.0-p247':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

所以,我尝试列出我拥有的版本。它告诉我我有1.9.3-p392,所以我卸载了那个并重新安装以查看它是否有效 - 同样的错误。

我需要重新安装/更新 xcode,还是有其他解决方案?

谢谢!

【问题讨论】:

标签: ruby rvm osx-mavericks


【解决方案1】:

如果您在升级到 Mavericks 后还没有升级 Xcode,您应该这样做 之后,打开命令提示符并输入:
xcode-select --install

这将安装已被 OSX 更新删除的 xcode 命令工具。 之后它应该可以正常工作了。

【讨论】:

  • 是的,更新 xcode 对我有用——虽然我不需要 xcode-select --install
  • 奇怪的是,我在 XCode 5 上,我仍然需要升级到 5.0.2 并且仍然必须运行上述命令。
  • 这对我来说失败,出现“不可用”错误。如果其他人发生这种情况:apple.stackexchange.com/questions/110463/…
  • 这只适用于小牛队吗? (10.8 说“xcode-select:错误:未知命令选项'--install'。)
  • 所有xcode-select --install 对我来说都是xcode-select: error: command line tools are already installed, use "Software Update" to install updates。我不得不
【解决方案2】:

建议的解决方案没有解决我的问题(最新版本的 XCode,安装了命令行工具)。我使用了rvm install ruby-1.9.3 --with-gcc=clang 并且有效。

我以为 rvm 默认使用 clang for OSX。不确定我是否记得错误或发生了什么变化/这不再是最好的选择。尽管如此,它使安装对我有用。

在 Edu 发表评论后,他引用的 github rvm issues page 发出警告:

@marksands 请确保你知道你在做什么,ruby 1.9.3 用clang编译不是“安全的”,它可以segfault,线程相关 预期的问题,考虑重新安装 ruby​​ --with-gcc=gcc42 或 就让rvm安装gcc 4.6,只有ruby 2.0.0完全兼容 叮当

This issue 指出 gcc46 在 Mavericks 上的问题:

有问题的 gem 使用不同的语言 - 不是 C/C++,它使用 Objective-C - 所以这不是编译器的错误,你可以构建 gcc-4.6 支持 Objective-C - 默认情况下没有这样做。

您现在有两个选择,都以卸载 gcc-4.6 和 那么:

• 安装 apple-gcc42

• 使用 --enable-objc 安装 gcc-4.6

【讨论】:

  • 也在小牛队工作过:rvm install ruby​​-1.8.7-p302 --with-gcc=clang
  • 使用 clang 安装不安全。 github.com/wayneeseguin/rvm/issues/2133
  • brew install gcc46 --enable-objc 对我有用。
  • 请注意,如果安装失败,您已经安装了 brew 的 gcc(当前为 gcc48),您需要先卸载它,然后再使用 --enable-objc 重新安装或--enable-all-languages.
【解决方案3】:

这应该是固定的,运行:

rvm get head
rvm remove 1.9.3
rvm install 1.9.3

不要使用额外的标志

【讨论】:

  • 我在 configure.log 中收到以下消息: [2013-10-31 11:59:14] ./configure ... 检查 C 编译器是否工作... 无配置: 错误:在/Users/Ann/.rvm/src/ruby-1.9.3-p448': configure: error: C compiler cannot create executables See config.log' 了解更多详情
  • /Users/Ann/.rvm/src/ruby-1.9.3-p448/config.log 中的内容
  • 我得到了完全相同的错误。这是 config.log:gist.github.com/jaimeohm/7377415
  • 运行sudo port uninstall apple-gcc42,然后再次运行来自答案的命令
【解决方案4】:

最终对我有用的是安装 XCode 然后运行 ​​Xcode 然后尝试重新安装。

【讨论】:

  • +1 太疯狂了,它可能只是工作......而且它确实有效!非常感谢!
  • 当您更新 Xcode 时,它​​希望您接受许可条款,并且无论如何您必须从首选项菜单安装开发工具。
【解决方案5】:

跑步

rvm_configure_env=('LDFLAGS=-L/opt/sm/pkg/active/lib' 'CFLAGS=-I/opt/sm/pkg/active/include' 'CPATH=/opt/sm/pkg/active/include')

更正了我在 Mavericks 中的编译器问题

【讨论】:

    【解决方案6】:

    解决方案:

    unset SDKROOT

    这对我有用。我希望它也适合你。

    我尝试重新安装 xcode 以及 xcode 开发人员工具。没用。同样的错误。

    尝试使用env -i bash —noprofile —norc 运行以查看您的环境变量是否导致问题进一步调查。

    【讨论】:

      【解决方案7】:

      遇到了同样的问题(在 10.8.5 上,都是最新的)。 Ruby 2.0.0 安装良好,但不是 1.9.3。这个解决方案对我有用。

      cd 进入 ruby​​ 路径(在 config.log 中找到),然后 问题.configure(包含所有选项,在 config.log 中找到)

      make
      make install
      

      然后:

      rvm use 1.9.3 --create
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-05-02
        • 1970-01-01
        • 2016-06-10
        • 1970-01-01
        • 2011-03-15
        • 1970-01-01
        • 1970-01-01
        • 2012-05-10
        相关资源
        最近更新 更多