如何在Mac OS X Lion中安装Ruby 1.9.3?

Kli*_*ian 56 ruby macos osx-lion

我正在尝试安装Ruby 1.9.3但是遇到了问题.我安装了RVM,然后键入:

rvm install 1.9.3
Run Code Online (Sandbox Code Playgroud)

输出说:

ERROR: Error running ' ./configure....
Run Code Online (Sandbox Code Playgroud)

日志说:

configure: WARNING: unrecognized options: --with-libyaml-dir 
checking build system type... x86_64-apple-darwin11.2.0 
checking host system type... x86_64-apple-darwin11.2.0 
checking target system type...x86_64-apple-darwin11.2.0 
checking whether the C compiler works... no
configure: error: in `/Users/myuser/.rvm/src/ruby-1.9.3-p0':
configure: error: C compiler cannot create executables See `config.log' for more details
Run Code Online (Sandbox Code Playgroud)

我从App Store下载了新的XCode并安装了它.

zza*_*man 118

尝试使用clang编译器而不是默认值:

rvm install 1.9.3 --with-gcc=clang
Run Code Online (Sandbox Code Playgroud)

  • 也为我工作过! (2认同)

Mar*_*c M 15

RVM需要gcc-4.2才能安装ruby 1.9.3.不幸的是,Lion不再包含gcc-4-2,只是llvm版本:

lrwxr-xr-x  1 root  wheel  12 15 feb 17:21 /usr/bin/gcc -> llvm-gcc-4.2
Run Code Online (Sandbox Code Playgroud)

如果您有Lion但从Snow Leopard升级,那么您可能仍然拥有gcc-4.2如果您有一个全新的Lion安装,您应该下载gcc-4.2.我建议下载这个包.

https://github.com/kennethreitz/osx-gcc-installer
Run Code Online (Sandbox Code Playgroud)

检查您现在是否安装了gcc-4.2:

-rwxr-xr-x  1 root  wheel  113024 16 may  2011 /usr/bin/gcc-4.2
lrwxr-xr-x  1 root  wheel      12 15 feb 17:21 /usr/bin/gcc -> llvm-gcc-4.2
Run Code Online (Sandbox Code Playgroud)

现在你可以像往常一样安装ruby 1.9.3:

rvm install 1.9.3
rvm use 1.9.3 --default
Run Code Online (Sandbox Code Playgroud)


jup*_*p0r 13

如果您只想安装并保持最新版本的Ruby(而不是在不同版本的ruby之间切换),您可以通过自制软件安装ruby :

brew install ruby
Run Code Online (Sandbox Code Playgroud)

  • 到目前为止,brew是在Mac OS Lion上安装Ruby 1.9的唯一方法.此线程中描述的所有其他建议对我来说都失败了.我尝试了RVM 1.13.7以及所有可能的选项,并且在编译阶段都失败了.只有brew能无缝地工作 (3认同)

Sea*_*ren 6

先试试这个:

rvm get latest
Run Code Online (Sandbox Code Playgroud)

这就是我的工作:

  rvm:
    version:      "rvm 1.9.2 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.3p0"
    date:         "2011-10-30"
    platform:     "x86_64-darwin11.2.0"
    patchlevel:   "2011-10-30 revision 33570"
    full_version: "ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]"
Run Code Online (Sandbox Code Playgroud)

  • 我用它修复了:rvm install 1.9.3 --with-gcc = clang (3认同)

Geo*_*rge 6

实际上,ruby-1.9.3-p125现在可以使用了gcc-llvm.但是,目前的稳定/最新版本rvm还没有(还).但这只是rvm谨慎,现在已经解决了主分支中的解决方法rvm.

只需升级rvm到主分支并安装/升级ruby:

GT-MBP:~ gthiruva$ rvm upgrade ruby-1.9.3-p0 1.9.3
Are you sure you wish to upgrade from ruby-1.9.3-p0 to     ruby-1.9.3-p125? (Y/n): Y
Installing new ruby ruby-1.9.3-p125
Fetching yaml-0.1.4.tar.gz to /Users/gthiruva/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /Users/gthiruva/.rvm/src
Configuring yaml in /Users/gthiruva/.rvm/src/yaml-0.1.4.
Compiling yaml in /Users/gthiruva/.rvm/src/yaml-0.1.4.
Installing yaml to /Users/gthiruva/.rvm/usr
The autodetected CC(/usr/bin/gcc-4.2) is LLVM based, it is not yet fully supported by
ruby and gems, please read `rvm requirements`, and set CC=/path/to/gcc .
Unable to install ruby ruby-1.9.3-p125.         Please install it manually to continue.
GT-MBP:~ gthiruva$ rvm get head
Original installed RVM version:

rvm 1.10.2 by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis
<mpapis@gmail.com>`enter code here` [https://rvm.beginrescueend.com/]
...
RVM reloaded!
GT-MBP:~ gthiruva$ rvm reload
RVM reloaded!
GT-MBP:~ gthiruva$ exec bash

rvm 1.10.2 by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> 
[https://rvm.beginrescueend.com/]

GT-MBP:~ gthiruva$ rvm upgrade ruby-1.9.3-p0 1.9.3
Are you sure you wish to upgrade from ruby-1.9.3-p0 to     ruby-1.9.3-p125? (Y/n): Y
Installing new ruby ruby-1.9.3-p125
...
Successfully migrated ruby-1.9.3-p0 to ruby-1.9.3-p125
Upgrade complete!
Run Code Online (Sandbox Code Playgroud)


spa*_*kle 6

  1. 打开Xcode
  2. 打开Xcode首选项
  3. 打开下载选项卡
  4. 检查命令行工具

Xcode截图