Ruby使用rbenv在OSX Lion上失败

时间:2012-03-01 22:30:12

标签: ruby osx-lion

我一直在尝试在我的Lion机器上安装Ruby(OSX 10.7.3)。

我安装了rbenv和ruby-build,我试图在我的机器上获得1.9.2-p290。以下是安装失败的输出:

$ rbenv install 1.9.2-p290
Downloading http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz...
Installing yaml-0.1.4...
Installed yaml-0.1.4 to /Users/CSC/.rbenv/versions/1.9.2-p290
Downloading http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz...
Installing ruby-1.9.2-p290...

BUILD FAILED

Inspect or clean up the working tree at /var/folders/vm/gcqcld015jx025m7qgtxvw0m0000gn/T/ruby-build.20120301140751.6239
Results logged to /var/folders/vm/gcqcld015jx025m7qgtxvw0m0000gn/T/ruby-build.20120301140751.6239.log

Last 10 log lines:
/usr/bin/gcc-4.2 -I. -I../../../.ext/include/x86_64-darwin11.3.0 -I../../.././include -I../../.././ext/racc/cparse -DRUBY_EXTCONF_H=\"extconf.h\" -I'/Users/SamCouch/.rbenv/versions/1.9.2-p290/include'  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long  -pipe  -o cparse.o -c cparse.c
/usr/bin/gcc-4.2 -dynamic -bundle -o ../../../.ext/x86_64-darwin11.3.0/racc/cparse.bundle cparse.o -L. -L../../.. -L. -L'/Users/SamCouch/.rbenv/versions/1.9.2-p290/lib'  -L/usr/local/lib -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace  -lpthread -ldl -lobjc 
compiling readline
/usr/bin/gcc-4.2 -I. -I../../.ext/include/x86_64-darwin11.3.0 -I../.././include -I../.././ext/readline -DRUBY_EXTCONF_H=\"extconf.h\" -I'/Users/SamCouch/.rbenv/versions/1.9.2-p290/include'  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long  -pipe  -o readline.o -c readline.c
readline.c: In function ‘username_completion_proc_call’:
readline.c:1386: error: ‘username_completion_function’ undeclared (first use in this function)
readline.c:1386: error: (Each undeclared identifier is reported only once
readline.c:1386: error: for each function it appears in.)
make[1]: *** [readline.o] Error 1
make: *** [mkmain.sh] Error 1

我试图解决这个问题,但到目前为止我还没有找到任何解决方案:

$ which gcc
/usr/bin/gcc
$ gcc
i686-apple-darwin11-llvm-gcc-4.2: no input files
$ ruby-build
ruby-build 20120216
usage: ruby-build [-v|--verbose] definition prefix
       ruby-build --definitions

非常感谢任何帮助!

作为旁注,我已经尝试了其他类似的建议,但没有一个对我有用。

4 个答案:

答案 0 :(得分:16)

每个ruby-build issue #130当前的解决方法是:

env CC=/usr/bin/gcc rbenv install 1.9.3-p125

我刚刚在一个系统上测试过这个:

  • OS X 10.7.3
  • Xcode 4.3.1
  • 安装了Xcode的命令行工具(通过Xcode>偏好设置>下载)
  • ruby​​-build @ fbfa944
  • rbenv @ 975b45d

此外,待处理的拉取请求#137旨在一劳永逸地解决此问题。

FWIW,很多人都在使用Xcode 4.3.x来解决构建链问题。如果你升级到新的工具链,直到集体尘埃落定,任何系统都会出现一些不稳定。

答案 1 :(得分:5)

使用rbenv通过1.9.x / homebrew在Mac OS X上安装ruby rbenv似乎存在两个或三个与错误相关的堆栈溢出问题没有运气就尝试了很多解决方案。设置编译器并通过自制软件安装apple gcc42编译器没有帮助(brew install apple-gcc42CC=/usr/bin/gcc - 没有运气)所以我不确定它们是否必要。我正在使用rbenv经理,因此在尝试安装1.9.3-p385时,这对我有用

问题在于日志显示的readline:

readline.c: In function ‘username_completion_proc_call’:
readline.c:1499: error: ‘username_completion_function’ undeclared (first use in this function)
readline.c:1499: error: (Each undeclared identifier is reported only once
readline.c:1499: error: for each function it appears in.)

因此,在专门查找该错误之后,我找到了解决方案:

解决方案:

brew install readline
CONFIGURE_OPTS="--with-readline-dir=$(brew --prefix readline)" rbenv install 1.9.3-p385

您可以命令rbenv install 1.9.3-p385部分命令匹配最新版本或您尝试安装的版本。找到关于this blog的说明。

答案 2 :(得分:0)

这可能会根据您所需要的水平而不是您直接询问的水平来回答,但是:您是否考虑过简单地使用macports(参见macports.org)或brew作为安装ruby 1.9的方式?它运作良好,而且工作量小得多。

答案 3 :(得分:0)

这并不是你要求的,但“Can't install Ruby under Lion with RVM – GCC issues”回答​​了如何让Ruby使用RVM处理Lion。错误非常相似,所以你可以:

使用它们作为rbenv故障排除的一些指导,或者只是使用顶部答案中描述的RVM以这种方式安装Ruby。这对我来说似乎更容易。