【问题标题】:Trouble downgrading Ruby on OS X Mavericks在 OS X Mavericks 上降级 Ruby 时遇到问题
【发布时间】:2013-06-11 10:01:45
【问题描述】:

OS X 10.9 附带 ruby​​ 2.0.0p195,但我需要安装 Ruby 1.8.7。我一直遇到错误。我已经安装了 Xcode5-DP,并且我相信命令行工具也已安装。

在终端中:

sudo rvm install 1.8.7
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10/x86_64/ruby-1.8.7-p371.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
Installing requirements for osx, might require sudo password.
Certificates in '/usr/local/etc/openssl/cert.pem' already are up to date.
Installing Ruby from source to: /Users/alextoul/.rvm/rubies/ruby-1.8.7-p371, this may take a while depending on your cpu(s)...
ruby-1.8.7-p371 - #downloading ruby-1.8.7-p371, this may take a while depending on your connection...
ruby-1.8.7-p371 - #extracted to /Users/alextoul/.rvm/src/ruby-1.8.7-p371 (already extracted)
Patch stdout-rouge-fix was already applied.
Patch no_sslv2 was already applied.
ruby-1.8.7-p371 - #configuring...
Error running 'env CFLAGS=-O3 -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libxml2/include -I/usr/local/opt/libxslt/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl098/include LDFLAGS=-L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libxml2/lib -L/usr/local/opt/libxslt/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl098/lib ./configure --prefix=/Users/alextoul/.rvm/rubies/ruby-1.8.7-p371 --disable-install-doc --without-tcl --without-tk --enable-shared',
please read /Users/alextoul/.rvm/log/ruby-1.8.7-p371/1371228839_configure.log
There has been an error while running configure. Halting the installation.

1371228839_configure.log 说:

./configure
configure: WARNING: unrecognized options: --without-tcl, --without-tk
checking build system type... i686-apple-darwin13.0.0
checking host system type... i686-apple-darwin13.0.0
checking target system type... i686-apple-darwin13.0.0
checking whether the C compiler works... no
configure: error: in `/Users/alextoul/.rvm/src/ruby-1.8.7-p371':
configure: error: C compiler cannot create executables
See `config.log' for more details

其他(有用的)信息:

ruby -v
> ruby 2.0.0p195 (2013-05-14 revision 40734) [universal.x86_64-darwin13]
brew update
> Already up-to-date.
gcc --version
> Configured with: --prefix=/Applications/Xcode5-DP.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode5-DP.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1
> Apple LLVM version 5.0 (clang-500.1.58) (based on LLVM 3.3svn)
> Target: x86_64-apple-darwin13.0.0
> Thread model: posix
sudo rvm requirements
> Installing requirements for osx, might require sudo password.
> Certificates in '/usr/local/etc/openssl/cert.pem' already are up to date.

感谢您的帮助。

【问题讨论】:

标签: ruby xcode macos rvm osx-mavericks


【解决方案1】:

10.9 是操作系统的早期测试版。 [编辑:请注意此答案的 2013 年 7 月日期]如果我运行的是 10.9,我会假设我必须从头开始重新安装操作系统至少 2 次。 (在 beta 周期中至少一次,因为它是 beta 版,而在 10.9 正式发布时,因为,好吧,beta 版)。

鉴于此,我建议采取四种行动方案(选择一种或多种):

  • 与 RVM 人员一起研究 10.9 可能已更改的编译器环境并编译 Ruby 1.8.7。这比较棘手,因为从技术上讲,这些东西都在 NDA 之下。
  • 相反,设置一个 VM 并在 VM 上运行 Ruby 1.8.7。使用 Vagrant 和 Chef/Puppet 的奖励积分,因为您甚至可能需要重建 VM。 (只需将 Vagrantfile 和 Puppet 或 Chef 配置文件保存在 Github/Dropbox/其他任何地方,这样您就可以克隆它们并从头开始重新生成您的虚拟机。)
  • 或者只需重新启动到 10.8 即可完成生产工作。 10.8 是生产级操作系统,应谨慎对待 10.9 - 它可能会吃掉你的工作。它真的不应该用于生产目的(又名:日常编写 Ruby 代码)。如果您在 Cocoa/Objective-C 中编写一个仅 10.9 的应用程序(或更新 RubyMotion 之类的),那可能是另一回事(但我仍然会保留良好的备份并温和地对待它)。
  • 努力为 Ruby 2.0 更新您的代码库,因为无论如何官方都不再支持 Ruby 1.8.7。

编辑(2013 年 10 月 24 日):如果您在这里是因为您刚刚安装了 Mavericks(2013 年 10 月 22 日发布),希望在此版本发布几天后让 Ruby 1.8.7 工作,并且 RVM 不适合您(因为您不耐烦并且等不及了),这是您可以做的(虽然我不是 rbenv 用户,但应该可以):

  1. 使用macports安装port install ruby。这是 Ruby 1.8.7。这个编译在我的 Mavericks 机器上为我工作(尽管在撰写本文时您需要从源代码安装 Macports安装命令行开发人员工具,即使您安装了 XCode 5。是的,真的)。
  2. 现在,安装rbenv
  3. /opt/local/bin/ruby1.8 文件夹中的符号链接 ~/.rbenv/versions/。具体~/.rbenv/versions/ruby-1.8.7-p374
  4. 阅读 rbenv 文档,但它现在应该可以工作了! (至少来自文档。同样,不是rbenv 用户,但可以在电视上播放)

我相信您也可以使用自制软件来做到这一点,但我知道 Ruby 1.8.7 可以在最新的 Macports 上正确安装,因为这是我使用的(它只是为我安装干净)。

【讨论】:

  • 如果有可能我会为答案的每一点 +1 ;)
  • 非常感谢.. 我向 RVM 人员提交了一个问题。它实际上也不适用于 Ruby 1.9.3,并且不确定我是否可以轻松升级到 Ruby 2.0.. 我现在将降级 OSx 并在第二台计算机上使用它..
  • 尝试使用 rbenv 而不是 rvm,这是 GitHub 上的人的首选,他们的 Boxen toolset 需要它,而 rvm 与它不兼容。我最近从 rvm 切换到 rbenv,部分是因为这个,而且它似乎至少也能正常工作(尽管略有不同)。我还没有在 Mavericks 上尝试过,所以我不知道它在这种情况下是否有效,但值得一试。看看这些文章:overacker.me/blog/2013/07/10/getting-started-with-rbenv & edapx.com/2013/05/23/switching-from-rvm-to-rbenv
  • 现在 Mavericks 已经公开发布,人们可以在公开场合谈论它,而不必担心 NDA。 RVM 团队 - 一方面 - 现在对 Mavericks 问题非常敏感(只需查看他们的 Github 问题跟踪器)。您可能不应该降级系统 Ruby,而是使用 RVM/rbenv 为旧项目安装单独的 Ruby。如果 rvm 安装失败,请与 RVM/rbenv 开发人员合作以获取工作的 Ruby。事实上,10.9 中的 REE 支持存在问题,现在有很多活动开放(例如)。或者等待一周,让 RVM 团队解决问题,更新 RVM 并重试。
  • @Beaon,因为我是个好人,我已经更新了我的答案,希望你能考虑一个实际的答案。
【解决方案2】:

当你看到这个错误信息时:

配置:错误:C 编译器无法创建可执行文件

首先,确保您已升级命令行工具:

$ xcode-select --install

现在 Apple 希望您在使用这些工具之前同意他们的许可:

$ gcc
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.

$ sudo gcc
You have not agreed to the Xcode license agreements. You must agree to both license agreements below in order to use Xcode.
[...]

接受后,命令行工具将按预期工作。

【讨论】:

  • 我收到错误消息:“无法安装该软件,因为软件更新服务器当前不提供该软件。”
  • 是的,我有 Xcode 5.0.2。我通过从 Apple 开发中心下载工具解决了这个问题。
【解决方案3】:

如果您在 OS X Mavericks 上安装了开发者工具,Ruby 1.8 已经与 2.0 一起安装。 因此,您需要做的就是将“当前”符号链接切换为指向 1.8 目录。

#Install Xcode Developer tools
xcode-select --install

#Delete Current symbolic link to Ruby 2.0
sudo rm /System/Library/Frameworks/Ruby.framework/Versions/Current

#Create new Current symbolic link to Ruby 1.8
sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/1.8 /System/Library/Frameworks/Ruby.framework/Versions/Current

#Check Ruby version is 1.8.7
ruby -v

【讨论】:

  • 这个对我有用,在尝试了两天之后。谢谢!
  • 顺便说一句,如果您需要回到 2.0,只需删除符号链接,然后创建一个新的 Current 符号链接,将 /1.8 部分替换为 /2.0
  • 如果您进行了免费的操作系统升级以便安装两者并立即修复您已经在 ruby​​1.8 上运行的任何内容,这将特别有效
【解决方案4】:

试试这个(确保开发工具链是可访问的):

$ sudo xcode-select -s /Applications/Xcode5-DP.app/Contents/Developer

然后重试。

【讨论】:

    【解决方案5】:

    尝试切换编译器

    rvm install 1.8.7 --with-gcc=clang
    

    【讨论】:

    • 这是自问问题,ruby-1.8.7clang 根本不兼容,第一次尝试使其工作是在 ruby-1.9.3 中完成的,但只有 ruby-1.9.3-p194 工作正常(最小问题)和ruby-2.0.0 是第一个使用clang 而不是gcc-4.2(GNU GCC)效果更好
    猜你喜欢
    • 2013-11-05
    • 1970-01-01
    • 2013-10-06
    • 1970-01-01
    • 1970-01-01
    • 2013-12-06
    • 2013-12-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多