在OSX Lion下使用RVM和Readline安装Ruby 1.9.2时出错

时间:2011-08-07 03:29:13

标签: ruby-on-rails-3 makefile rvm readline osx-lion

我遇到了很多问题,让rvm再次在OSX Lion下工作。不出所料,它似乎是readline的问题,这在几个地方都有提及。

但是,(这是一次更新)似乎readline本身没有正确安装!

这是我到目前为止所尝试的内容:

重新安装xcode(4.1)(我还首先删除了Developer文件夹。)

根据http://trac.macports.org/wiki/Migration

清理并重新安装我的所有端口

按照https://rvm.beginrescueend.com/packages/readline/

重新安装readline

使用该特定的readline版本:

rvm install 1.9.2 --with-readline-dir=$rvm_path/usr

我还完全重新安装了rvm。仍然没有去。这是我看到的当前错误:

ERROR: Error running 'make ', please read /Users/tristankromer/.rvm/log/ruby-1.9.2-p290/make.log
ERROR: There has been an error while running make. Halting the installation.

...以及随附的日志文件。

make[1]: Entering directory `/Users/tristankromer/.rvm/src/ruby-1.9.2-p290/ext/readline'
/usr/bin/gcc-4.2 -I. -I../../.ext/include/x86_64-darwin11.0.0 -I../.././include -I../.././ext/readline -DRUBY_EXTCONF_H=\"extconf.h\" -I/Users/tristankromer/.rvm/usr/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  -fno-common -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[1]: Leaving directory `/Users/tristankromer/.rvm/src/ruby-1.9.2-p290/ext/readline'
make: *** [mkmain.sh] Error 1

经过多次调查后,我尝试手动安装readline :(来自:RVM Does Not Install Ruby 1.9.2 on Snow Leopard: 'Error running 'make '

curl -O ftp://ftp.gnu.org/gnu/readline/readline-6.1.tar.gz
tar xzvf readline-6.1.tar.gz
cd readline-6.1
./configure --prefix=/usr/local
make
sudo make install
cd ..

当我收到编译readline的错误时,我得到了make:

gcc-4.2 -dynamic -arch_only `/usr/bin/arch` -install_name /usr/local/lib/libreadline.6.1.dylib -current_version 6.1 -compatibility_version 6 -v -o libreadline.6.1.dylib readline.so vi_mode.so funmap.so keymaps.so parens.so search.so rltty.so complete.so bind.so isearch.so display.so signals.so util.so kill.so undo.so macro.so input.so callback.so terminal.so text.so nls.so misc.so xmalloc.so history.so histexpand.so histfile.so histsearch.so shell.so mbutil.so tilde.so compat.so -lncurses
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/gcc/gcc-5666.3~278/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
i686-apple-darwin11-gcc-4.2.1: -compatibility_version only allowed with -dynamiclib
make[1]: *** [libreadline.6.1.dylib] Error 1
make[1]: Leaving directory `/Users/tristankromer/src/readline-6.1/shlib'
make: [shared] Error 2 (ignored)

所以看起来甚至安装readline我都有问题,因为readline。

然后我通过添加.bash_profile:

跟随Andy的指示(下面)
export ARCHFLAGS="-arch x86_64"

并跑了:

brew install readline
brew link readline
brew install libxml2
brew link libxml2
rvm install 1.9.2 -C --with-readline-dir=/usr/local/Cellar/readline/6.2.1/ --with-libxml2-dir=/usr/local/Cellar/xml2/2.7.8

现在我似乎有一个不同的错误:

make[1]: Entering directory `/Users/tristankromer/.rvm/src/ruby-1.9.2-p290/ext/tk'
/usr/bin/gcc-4.2 -dynamic -bundle -o ../../.ext/x86_64-darwin11.0.0/tcltklib.bundle stubs.o tcltklib.o -L. -L../.. -L/System/Library/Frameworks/Tcl.framework -L/System/Library/Frameworks/Tk.framework -L. -L/usr/local/lib   -lpthread -framework CoreFoundation  -F/System/Library/Frameworks -framework Tcl    -lpthread -framework CoreFoundation -framework Cocoa -framework Carbon -framework IOKit   -lpthread -framework CoreFoundation  -F/System/Library/Frameworks -framework Tk -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace  -lruby.1.9.1 -lm -ldl  -lpthread -ldl -lobjc
ld: in /usr/local/lib/libiconv.2.dylib, missing required architecture x86_64 in file for architecture x86_64
collect2: ld returned 1 exit status
make[1]: *** [../../.ext/x86_64-darwin11.0.0/tcltklib.bundle] Error 1
make[1]: Leaving directory `/Users/tristankromer/.rvm/src/ruby-1.9.2-p290/ext/tk'
make: *** [mkmain.sh] Error 1

4 个答案:

答案 0 :(得分:12)

我有一个非常类似的问题。我最终发现将此添加到我的.bash_profile会停止我的初始make错误:

export ARCHFLAGS="-arch x86_64"

同样从命令行运行以下命令:

brew install readline
brew link readline
brew install libxml2
brew link libxml2

然后当你安装ruby时使用这个命令:

rvm install 1.9.2 -C --with-readline-dir=/usr/local/Cellar/readline/6.2.1/ --with-libxml2-dir=/usr/local/Cellar/xml2/2.7.8

希望有所帮助

答案 1 :(得分:5)

我刚才有类似的错误,之前的答案对我没有帮助。我在这里找到了解决方案:https://rvm.io/packages/readline

rvm pkg install readline
rvm reinstall 1.9.2 --with-readline-dir=$rvm_path/usr

答案 2 :(得分:0)

你有一个更新的狮子兼容版Xcode? (4.1我认为)

答案 3 :(得分:0)

  1. 从/ usr / local /或安装它们的任何位置卸载/删除所有手动安装的旧ruby版本和附加内容(sqlite3,libxml2-x.x.x,libxslt-x.x.x)的痕迹。
  2. 下载并安装JewlryBox http://unfiniti.com/software/mac/jewelrybox,这是一个用于管理红宝石和宝石的RVM GUI界面。
  3. 在JewlryBox中,单击“添加Ruby”并选择要安装的ruby版本(我选择了64位,启用了共享,但没有选中/勾选“使用clang”选项)。
  4. 安装了OS X Lion 10.7.3和Xcode 4.3命令行工具。