在macOS 10.13(High Sierra)上安装Ruby 1.9.x

时间:2018-04-07 09:28:00

标签: ruby macos gcc rbenv macos-high-sierra

我最近决定查看运行Ruby 1.9.2的旧Rails应用程序,并决定尝试在我的macOS 10.13计算机上安装1.9.2。

我知道gcc不再附带macOS所以我记得使用Homebrew Core的apple-gcc42配方的旧技巧,遗憾的是这个版本的最高版本是10.9(Mavericks)。无论如何我都试过运气,甚至跟着rbenv's gcc compatibility notes

  

(请注意,Ruby< 2.0没有with-readline-dir标志;请改用-opt-dir。)

我尝试了以下命令(请注意,我已经安装了rbenv&#39的ruby-build插件并且是最新的):

RUBY_CONFIGURE_OPTS="--with-opt-dir=/usr/local/opt/" CC=/usr/local/bin/gcc-4.2 rbenv install 1.9.2-p180
ruby-build: use libyaml from homebrew
  Downloading ruby-1.9.2-p180.tar.bz2...
  -> https://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p180.tar.bz2
  Installing ruby-1.9.2-p180...

  WARNING: ruby-1.9.2-p180 is past its end of life and is now unsupported.
  It no longer receives bug fixes or critical security updates.

  ruby-build: use readline from homebrew

  BUILD FAILED (OS X 10.13.3 using ruby-build 20180329)

  Inspect or clean up the working tree at /var/folders/0t/hft4_1h13wqd91mwcw2j94h80000gn/T/ruby-build.20180407090310.93949
  Results logged to /var/folders/0t/hft4_1h13wqd91mwcw2j94h80000gn/T/ruby-build.20180407090310.93949.log

  Last 10 log lines:
  /var/folders/0t/hft4_1h13wqd91mwcw2j94h80000gn/T/ruby-build.20180407090310.93949 /usr/local/bin
  /var/folders/0t/hft4_1h13wqd91mwcw2j94h80000gn/T/ruby-build.20180407090310.93949/ruby-1.9.2-p180 /var/folders/0t/hft4_1h13wqd91mwcw2j94h80000gn/T/ruby-build.20180407090310.93949 /usr/local/bin
  configure: WARNING: unrecognized options: --with-openssl-dir, --with-libyaml-dir, --with-readline-dir
  checking build system type... i386-apple-darwin17.4.0
  checking host system type... i386-apple-darwin17.4.0
  checking target system type... i386-apple-darwin17.4.0
  checking whether the C compiler works... no
  configure: error: in `/var/folders/0t/hft4_1h13wqd91mwcw2j94h80000gn/T/ruby-build.20180407090310.93949/ruby-1.9.2-p180':
  configure: error: C compiler cannot create executables
  See `config.log' for more details

config.log上的错误与上面的一个输出相同:

  

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

我尝试使用C代码编译基本文件而gcc-4.2未能这样做(与/usr/local/bin/gcc不同),我告诉我gcc-4.2根本无法在macOS 10.13上工作马上。也许前进的唯一方法是找到一种用现代gcc版本编译旧Rubies的方法,但我猜测这可能涉及对configure文件进行大量手动更改以使它们兼容。 / p>

我只是好奇是否有人在这项努力中取得了成功,或者这是否是一个失败的原因。

1 个答案:

答案 0 :(得分:1)

rvm可能有可能查看https://github.com/rvm/rvm/issues/3099以及https://github.com/rvm/rvm/issues/3876

您应该可以安装ruby-1.9.3

但如果这不起作用,您可以考虑启动docker ubuntu容器并以这种方式安装它吗? https://github.com/rvm/ubuntu_rvm