我尝试使用rbenv安装ruby版本2.0.0-p353,但它输出错误并输出以下内容:
linking shared-object openssl.so
installing default openssl libraries
make[2]: Leaving directory `/tmp/ruby-build.20140828155903.3436/ruby-2.0.0-p353/ext/openssl'
make[2]: Entering directory `/tmp/ruby-build.20140828155903.3436/ruby-2.0.0-p353/ext/pathname'
compiling pathname.c
linking shared-object pathname.so
installing default pathname libraries
make[2]: Leaving directory `/tmp/ruby-build.20140828155903.3436/ruby-2.0.0-p353/ext/pathname'
make[2]: Entering directory `/tmp/ruby-build.20140828155903.3436/ruby-2.0.0-p353/ext/psych'
compiling psych.c
compiling psych_parser.c
compiling psych_emitter.c
compiling psych_to_ruby.c
compiling psych_yaml_tree.c
linking shared-object psych.so
installing default psych libraries
make[2]: Leaving directory `/tmp/ruby-build.20140828155903.3436/ruby-2.0.0-p353/ext/psych'
make[2]: Entering directory `/tmp/ruby-build.20140828155903.3436/ruby-2.0.0-p353/ext/pty'
compiling pty.c
pty.c: In function ‘chfunc’:
pty.c:143:12: warning: ignoring return value of ‘seteuid’, declared with attribute warn_unused_result [-Wunused-result]
seteuid(getuid());
^
linking shared-object pty.so
installing default pty libraries
make[2]: Leaving directory `/tmp/ruby-build.20140828155903.3436/ruby-2.0.0-p353/ext/pty'
make[2]: Entering directory `/tmp/ruby-build.20140828155903.3436/ruby-2.0.0-p353/ext/racc/cparse'
compiling cparse.c
linking shared-object racc/cparse.so
installing default cparse libraries
make[2]: Leaving directory `/tmp/ruby-build.20140828155903.3436/ruby-2.0.0-p353/ext/racc/cparse'
make[2]: Entering directory `/tmp/ruby-build.20140828155903.3436/ruby-2.0.0-p353/ext/readline'
compiling readline.c
readline.c: In function ‘Init_readline’:
readline.c:1886:26: error: ‘Function’ undeclared (first use in this function)
rl_pre_input_hook = (Function *)readline_pre_input_hook;
^
readline.c:1886:26: note: each undeclared identifier is reported only once for each function it appears in
readline.c:1886:36: error: expected expression before ‘)’ token
rl_pre_input_hook = (Function *)readline_pre_input_hook;
^
readline.c: At top level:
readline.c:530:1: warning: ‘readline_pre_input_hook’ defined but not used [-Wunused-function]
readline_pre_input_hook(void)
^
make[2]: *** [readline.o] Error 1
make[2]: Leaving directory `/tmp/ruby-build.20140828155903.3436/ruby-2.0.0-p353/ext/readline'
make[1]: *** [ext/readline/all] Error 2
make[1]: Leaving directory `/tmp/ruby-build.20140828155903.3436/ruby-2.0.0-p353'
make: *** [build-ext] Error 2
解决方案 事实证明这个问题实际上非常普遍,在这里讨论了很多:https://github.com/sstephenson/ruby-build/issues/526
使用此链接中的此调用解决了该问题:
$ RUBY_CONFIGURE_OPTS=--with-readline-dir="/usr/lib/x86_64-linux-gnu/libreadline.so" rbenv install 2.0.0-p353