在Mac OS X Lion上安装Ruby 1.9.3时出现错误

3

我想在MAC OS X Lion上安装Ruby 1.9.3和Rails。(我的Xcode版本是4.3)

(我已经安装了Rails 3.2.2)

无论我使用什么命令:

rvm install 1.9.3 --with-gcc=clang

或者:

rvm install 1.9.3

我的终端显示:

Error running 'make ', please read /Users/AlexHo/.rvm/log/ruby-1.9.3-p125/make.log
There has been an error while running make. Halting the installation.

有没有人遇到过相同的情况?
AlexHo@Nien-Yi-Hos-MacBook:~$ rvm install 1.9.3
Fetching yaml-0.1.4.tar.gz to /Users/AlexHo/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /Users/AlexHo/.rvm/src
Configuring yaml in /Users/AlexHo/.rvm/src/yaml-0.1.4.
Compiling yaml in /Users/AlexHo/.rvm/src/yaml-0.1.4.
Installing yaml to /Users/AlexHo/.rvm/usr
Installing Ruby from source to: /Users/AlexHo/.rvm/rubies/ruby-1.9.3-p125, this may take a while depending on your cpu(s)...

ruby-1.9.3-p125 - #fetching 
ruby-1.9.3-p125 - #extracted to /Users/AlexHo/.rvm/src/ruby-1.9.3-p125 (already extracted)
ruby-1.9.3-p125 - #configuring 
ruby-1.9.3-p125 - #compiling 
Error running 'make ', please read /Users/AlexHo/.rvm/log/ruby-1.9.3-p125/make.log
There has been an error while running make. Halting the installation.

AlexHo@Nien-Yi-Hos-MacBook:~$ cat /Users/AlexHo/.rvm/log/ruby-1.9.3-p125/make.log
[2012-03-03 04:15:53] make 
        CC = clang
        LD = ld
        LDSHARED = clang -dynamiclib
        CFLAGS = -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=shorten-64-to-32 -Werror=implicit-function-declaration  -fno-common -pipe 
    XCFLAGS = -include ruby/config.h -include ruby/missing.h -fvisibility=hidden -DRUBY_EXPORT
    CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I. -I.ext/include/x86_64-darwin11.3.0 -I./include -I.
    DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace -install_name /Users/AlexHo/.rvm/rubies/ruby-1.9.3-p125/lib/libruby.1.9.1.dylib -current_version 1.9.1 -compatibility_version 1.9.1 -Wl,-unexported_symbol,_Init_* -Wl,-unexported_symbol,*_threadptr_*  -Wl,-u,_objc_msgSend   
    SOLIBS = 
linking miniruby
rbconfig.rb unchanged
generating enc.mk
generating prelude.c
compiling prelude.c
linking static-library libruby.1.9.1-static.a
linking shared-library libruby.1.9.1.dylib
generating encdb.h
encdb.h unchanged
making enc
make[1]: Nothing to be done for `enc'.
making srcs under enc
make[1]: Nothing to be done for `srcs'.
generating transdb.h
transdb.h unchanged
making trans
make[1]: Nothing to be done for `./enc/trans'.
making encs
installing default bug libraries
installing default resize libraries
installing default bug libraries
installing default bug libraries
installing default funcall libraries
installing default dot.dot libraries
installing default old_thread_select libraries
installing default numhash libraries
installing default string libraries
installing default wait_for_single_fd libraries
installing default bigdecimal libraries
installing default continuation libraries
installing default coverage libraries
installing default curses libraries
installing default date_core libraries
make[2]: Nothing to be done for `all'.
installing digest libraries
installing default digest libraries
installing default bubblebabble libraries
installing default md5 libraries
installing default rmd160 libraries
installing default sha1 libraries
installing default sha2 libraries
installing dl libraries
installing default dl libraries
installing default callback libraries
make[2]: Nothing to be done for `all'.
installing default etc libraries
installing default fcntl libraries
installing default fiber libraries
installing default fiddle libraries
make[2]: Nothing to be done for `all'.
installing default iconv libraries
installing default console libraries
installing default nonblock libraries
installing default wait libraries
installing default libraries
installing default generator libraries
installing default parser libraries
installing default complex libraries
installing default rational libraries
installing default nkf libraries
installing default objspace libraries
installing default openssl libraries
installing default pathname libraries
installing default psych libraries
installing default pty libraries
installing default cparse libraries
compiling readline.c
readline.c:1499:9: error: use of undeclared identifier 'username_completion_function'; did you mean 'rl_username_completion_function'?
                                    rl_username_completion_function);
                                    ^
readline.c:69:42: note: instantiated from:
# define rl_username_completion_function username_completion_function
                                         ^
/usr/local/include/readline/readline.h:449:14: note: 'rl_username_completion_function' declared here
extern char *rl_username_completion_function PARAMS((const char *, int));
             ^
    1 error generated.
    make[2]: *** [readline.o] Error 1
    make[1]: *** [ext/readline/all] Error 2
    make: *** [build-ext] Error 2

日志文件中引用了什么内容? - Andrew Marshall
嗨,安德鲁,我已经在问题中进行了更新。 - hitheredude
请将 cat /Users/AlexHo/.rvm/log/ruby-1.9.3-p125/make.log 的输出粘贴在问题中。 - TheDelChop
@TheDelChop 我已经更新了。谢谢。 - hitheredude
我有完全相同的问题!在我的情况下,我尝试了 m8:~ m8$ cd $HOME/.rvm/src/ruby-1.9.2-p318/ext/readline m8:readline m8$ ruby extconf.rb -- --with-readline-dir="$HOME/.rvm/usr",如果之后我运行 m8:readline m8$ make install,我会得到很多奇怪的 cc -arch i386 -arch x86_64 -pipe -bundle -undefined dynamic_lookup -o readline.bundle readline.o -L. -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L/Users/m8/.rvm/usr/lib -L. -arch i386 -arch x86_64 … 的东西。 - matt
2个回答

4

我自己也遇到了这个问题,经过长时间的挣扎和搜索(没有一个网站提供完整的解决方案),我最终得出了以下解决方法:

curl -O ftp://ftp.gnu.org/gnu/readline/readline-6.2.tar.gz
tar xzvf readline-6.2.tar.gz
cd readline-6.2
./configure --prefix=/usr/local
cd shlib
sed -e 's/-dynamic/-dynamiclib/' Makefile > Makefile.good
mv Makefile.good Makefile
cd ..
make
sudo make install
cd ..
rvm install 1.9.3 -C --with-readline-dir=/usr/local/

谢谢!这对于1.9.3版本对我有用——但是在1.8.7版本上仍然有问题。 - derks

3
尝试看一下这个链接,似乎你的问题与readline有关,rvm有一个完整的部分关于如何处理readline错误。 http://rvm.io/packages/readline/

我现在已经安装了Rails 3.2.2,但仍然无法将Ruby从1.8.7更新到1.9.3... - hitheredude

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接