【问题标题】:How to get Readline support in IRB using RVM on Ubuntu 11.10如何在 Ubuntu 11.10 上使用 RVM 在 IRB 中获得 Readline 支持
【发布时间】:2023-03-20 15:40:01
【问题描述】:

我已经尝试了所有我能想到的方法来让它工作,但无济于事,所以我在这里请求有关如何调试的建议。

首先,运行 Ubuntu 11.10

已安装的 rvm:

$ bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

使用 apt-get 安装 readline:

$ sudo apt-get install libreadline-dev

检查 readline 安装:

$ dpkg --get-selections | grep readline
lib64readline-gplv2-dev             install
lib64readline5                  install
libreadline-dev                 install
libreadline5                    install
libreadline6                    install
libreadline6-dev                install
readline-common                 install

安装 ruby​​,是否支持 readline?

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

这里是 rvm 版本:

$ rvm --version

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

让我们试试 ruby​​ shell:

$ irb
1.9.2 :001 > puts "add history"
add history
 => nil 
1.9.2 :002 > ^[[A^[[A^[[A^[[A^[[A <------ PRESS UP ARROW DOES THIS

不,好吧,如果它不能与 ubuntu 的 readline 版本一起工作???让我们试试 rvm 自己的 readline 版本:

$ rvm pkg install readline
Fetching readline-5.2.tar.gz to /home/keith/.rvm/archives
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1989k  100 1989k    0     0   318k      0  0:00:06  0:00:06 --:--:--  418k
Extracting readline-5.2.tar.gz to /home/keith/.rvm/src
Applying patch '/home/keith/.rvm/patches/readline-5.2/shobj-conf.patch'...
Prepare readline in /home/keith/.rvm/src/readline-5.2.
ERROR: Error running 'autoreconf -is --force', please read /home/keith/.rvm/log/readline/autoreconf.log
Configuring readline in /home/keith/.rvm/src/readline-5.2.
Compiling readline in /home/keith/.rvm/src/readline-5.2.
Installing readline to /home/keith/.rvm/usr
Fetching readline-6.2.tar.gz to /home/keith/.rvm/archives
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 2224k  100 2224k    0     0   310k      0  0:00:07  0:00:07 --:--:--  444k
Extracting readline-6.2.tar.gz to /home/keith/.rvm/src
Applying patch '/home/keith/.rvm/patches/readline-6.2/patch-shobj-conf.diff'...
Prepare readline in /home/keith/.rvm/src/readline-6.2.
ERROR: Error running 'autoreconf -is --force', please read /home/keith/.rvm/log/readline/autoreconf.log
Configuring readline in /home/keith/.rvm/src/readline-6.2.
Compiling readline in /home/keith/.rvm/src/readline-6.2.
Installing readline to /home/keith/.rvm/usr

好的,这里有错误,我们看看:

$ more /home/keith/.rvm/log/readline/autoreconf.log
[2011-11-17 22:31:15] autoreconf -is --force
autoheader: warning: missing template: CTYPE_NON_ASCII
autoheader: Use AC_DEFINE([CTYPE_NON_ASCII], [], [Description])
autoheader: warning: missing template: FIONREAD_IN_SYS_IOCTL
autoheader: warning: missing template: HAVE_BSD_SIGNALS
autoheader: warning: missing template: HAVE_GETPW_DECLS
autoheader: warning: missing template: HAVE_LANGINFO_CODESET
autoheader: warning: missing template: HAVE_MBRLEN
autoheader: warning: missing template: HAVE_MBSCMP
autoheader: warning: missing template: HAVE_MBSNRTOWCS
autoheader: warning: missing template: HAVE_MBSRTOWCS
autoheader: warning: missing template: HAVE_MBSTATE_T
autoheader: warning: missing template: HAVE_POSIX_SIGNALS
autoheader: warning: missing template: HAVE_POSIX_SIGSETJMP
autoheader: warning: missing template: HAVE_STRUCT_DIRENT_D_FILENO
autoheader: warning: missing template: HAVE_STRUCT_DIRENT_D_INO
autoheader: warning: missing template: HAVE_USG_SIGHOLD
autoheader: warning: missing template: HAVE_WCRTOMB
autoheader: warning: missing template: HAVE_WCSCOLL
autoheader: warning: missing template: HAVE_WCSDUP
autoheader: warning: missing template: HAVE_WCTYPE
autoheader: warning: missing template: HAVE_WCWIDTH
autoheader: warning: missing template: MUST_REINSTALL_SIGHANDLERS
autoheader: warning: missing template: NO_MULTIBYTE_SUPPORT
autoheader: warning: missing template: SPEED_T_IN_SYS_TYPES
autoheader: warning: missing template: STRCOLL_BROKEN
autoheader: warning: missing template: STRUCT_WINSIZE_IN_SYS_IOCTL
autoheader: warning: missing template: STRUCT_WINSIZE_IN_TERMIOS
autoheader: warning: missing template: TIOCSTAT_IN_SYS_IOCTL
autoheader: warning: missing template: VOID_SIGHANDLER
autoreconf: /usr/bin/autoheader failed with exit status: 1

正如预期的那样,irb 不能与 readline 一起使用:

$ rvm install 1.8.7 --with-readline-dir=\$HOME/.rvm/usr
Installing Ruby from source to: /home/keith/.rvm/rubies/ruby-1.8.7-p352, this may take a while depending on your cpu(s)...

ruby-1.8.7-p352 - #fetching 
ruby-1.8.7-p352 - #extracting ruby-1.8.7-p352 to /home/keith/.rvm/src/ruby-1.8.7-p352
ruby-1.8.7-p352 - #extracted to /home/keith/.rvm/src/ruby-1.8.7-p352
Applying patch 'stdout-rouge-fix' (located at /home/keith/.rvm/patches/ruby/1.8.7/stdout-rouge-fix.patch)
ruby-1.8.7-p352 - #configuring 
ruby-1.8.7-p352 - #compiling 
ruby-1.8.7-p352 - #installing 
Removing old Rubygems files...
Installing rubygems-1.8.10 for ruby-1.8.7-p352 ...
Installation of rubygems completed successfully.
ruby-1.8.7-p352 - adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-1.8.7-p352 - #importing default gemsets (/home/keith/.rvm/gemsets/)
Install of ruby-1.8.7-p352 - #complete 
$ irb
Readline was unable to be required, if you need completion or history install readline then reinstall the ruby.
You may follow 'rvm notes' for dependencies and/or read the docs page https://rvm.beginrescueend.com/packages/readline/ . Be sure you 'rvm remove X ; rvm install X' to re-compile your ruby with readline support after obtaining the readline libraries.
1.8.7 :001 > 

我是否安装了所有 rvm 要求?是的,看这里:

$ sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libxslt1-dev' instead of 'libxslt-dev'
Note, selecting 'libncurses5-dev' instead of 'ncurses-dev'
autoconf is already the newest version.
automake is already the newest version.
bison is already the newest version.
build-essential is already the newest version.
curl is already the newest version.
git-core is already the newest version.
libc6-dev is already the newest version.
libncurses5-dev is already the newest version.
libreadline6 is already the newest version.
libreadline6-dev is already the newest version.
libreadline6-dev set to manually installed.
libsqlite3-0 is already the newest version.
libsqlite3-dev is already the newest version.
libssl-dev is already the newest version.
libtool is already the newest version.
libxml2-dev is already the newest version.
libxslt1-dev is already the newest version.
libyaml-dev is already the newest version.
openssl is already the newest version.
sqlite3 is already the newest version.
subversion is already the newest version.
zlib1g is already the newest version.
zlib1g-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

就这样继续下去,一直在继续……

$ rvm remove 1.8.7
Removing /home/keith/.rvm/src/ruby-1.8.7-p352...
Removing /home/keith/.rvm/rubies/ruby-1.8.7-p352...
Removing ruby-1.8.7-p352 aliases...
Removing ruby-1.8.7-p352 wrappers...
Removing ruby-1.8.7-p352 environments...
Removing ruby-1.8.7-p352 binaries...

$ rvm install 1.8.7 --with-readline-dir=\$HOME/.rvm/usr
Installing Ruby from source to: /home/keith/.rvm/rubies/ruby-1.8.7-p352, this may take a while depending on your cpu(s)...

ruby-1.8.7-p352 - #fetching 
ruby-1.8.7-p352 - #extracting ruby-1.8.7-p352 to /home/keith/.rvm/src/ruby-1.8.7-p352
ruby-1.8.7-p352 - #extracted to /home/keith/.rvm/src/ruby-1.8.7-p352
Applying patch 'stdout-rouge-fix' (located at /home/keith/.rvm/patches/ruby/1.8.7/stdout-rouge-fix.patch)
ruby-1.8.7-p352 - #configuring 
ruby-1.8.7-p352 - #compiling 
ruby-1.8.7-p352 - #installing 
Removing old Rubygems files...
Installing rubygems-1.8.10 for ruby-1.8.7-p352 ...
Installation of rubygems completed successfully.
ruby-1.8.7-p352 - adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-1.8.7-p352 - #importing default gemsets (/home/keith/.rvm/gemsets/)
Install of ruby-1.8.7-p352 - #complete 

$ irb
Readline was unable to be required, if you need completion or history install readline then reinstall the ruby.
You may follow 'rvm notes' for dependencies and/or read the docs page https://rvm.beginrescueend.com/packages/readline/ . Be sure you 'rvm remove X ; rvm install X' to re-compile your ruby with readline support after obtaining the readline libraries.
1.8.7 :001 > 

$ cd ~/.rvm/src/ruby-1.8.7-p352/ext/readline/
$ ruby extconf.rb 
checking for tgetnum() in -lncurses... yes
checking for readline/readline.h... yes
checking for readline/history.h... yes
checking for readline() in -lreadline... yes
checking for rl_filename_completion_function()... yes
checking for rl_username_completion_function()... yes
checking for rl_completion_matches()... yes
checking for rl_deprep_term_function in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_completion_append_character in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_basic_word_break_characters in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_completer_word_break_characters in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_basic_quote_characters in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_completer_quote_characters in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_filename_quote_characters in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_attempted_completion_over in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_library_version in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_event_hook in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_cleanup_after_signal()... yes
checking for rl_clear_signals()... yes
checking for rl_vi_editing_mode()... yes
checking for rl_emacs_editing_mode()... yes
checking for replace_history_entry()... yes
checking for remove_history()... yes
creating Makefile

$ make
gcc -shared -o readline.so readline.o -L. -L/home/keith/.rvm/rubies/ruby-1.8.7-p352/lib -Wl,-R/home/keith/.rvm/rubies/ruby-1.8.7-p352/lib -L.  -rdynamic -Wl,-export-dynamic    -Wl,-R -Wl,/home/keith/.rvm/rubies/ruby-1.8.7-p352/lib -L/home/keith/.rvm/rubies/ruby-1.8.7-p352/lib -lruby -lreadline -lncurses  -lrt -ldl -lcrypt -lm   -lc

$ make install
/usr/bin/install -c -m 0755 readline.so /home/keith/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/i686-linux

$ rvm remove 1.8.7
Removing /home/keith/.rvm/src/ruby-1.8.7-p352...
Removing /home/keith/.rvm/rubies/ruby-1.8.7-p352...
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Removing ruby-1.8.7-p352 aliases...
Removing ruby-1.8.7-p352 wrappers...
Removing ruby-1.8.7-p352 environments...
Removing ruby-1.8.7-p352 binaries...

$ rvm install 1.8.7 --with-readline-dir=\$HOME/.rvm/usr
Installing Ruby from source to: /home/keith/.rvm/rubies/ruby-1.8.7-p352, this may take a while depending on your cpu(s)...
ruby-1.8.7-p352 - #fetching 
ruby-1.8.7-p352 - #extracting ruby-1.8.7-p352 to /home/keith/.rvm/src/ruby-1.8.7-p352
ruby-1.8.7-p352 - #extracted to /home/keith/.rvm/src/ruby-1.8.7-p352
Applying patch 'stdout-rouge-fix' (located at /home/keith/.rvm/patches/ruby/1.8.7/stdout-rouge-fix.patch)
ruby-1.8.7-p352 - #configuring 
ruby-1.8.7-p352 - #compiling 
ruby-1.8.7-p352 - #installing 
Removing old Rubygems files...
Installing rubygems-1.8.10 for ruby-1.8.7-p352 ...
Installation of rubygems completed successfully.
ruby-1.8.7-p352 - adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-1.8.7-p352 - #importing default gemsets (/home/keith/.rvm/gemsets/)
Install of ruby-1.8.7-p352 - #complete 

$ irb
Readline was unable to be required, if you need completion or history install readline then reinstall the ruby.
You may follow 'rvm notes' for dependencies and/or read the docs page https://rvm.beginrescueend.com/packages/readline/ . Be sure you 'rvm remove X ; rvm install X' to re-compile your ruby with readline support after obtaining the readline libraries.
1.8.7 :001 > $ 

$ rvm pkg install readline
Fetching readline-5.2.tar.gz to /home/keith/.rvm/archives
Extracting readline-5.2.tar.gz to /home/keith/.rvm/src
Applying patch '/home/keith/.rvm/patches/readline-5.2/shobj-conf.patch'...
Prepare readline in /home/keith/.rvm/src/readline-5.2.
ERROR: Error running 'autoreconf -is --force', please read /home/keith/.rvm/log/readline/autoreconf.log
Configuring readline in /home/keith/.rvm/src/readline-5.2.
Compiling readline in /home/keith/.rvm/src/readline-5.2.
Installing readline to /home/keith/.rvm/usr
Fetching readline-6.2.tar.gz to /home/keith/.rvm/archives
Extracting readline-6.2.tar.gz to /home/keith/.rvm/src
Applying patch '/home/keith/.rvm/patches/readline-6.2/patch-shobj-conf.diff'...
Prepare readline in /home/keith/.rvm/src/readline-6.2.
ERROR: Error running 'autoreconf -is --force', please read /home/keith/.rvm/log/readline/autoreconf.log
Configuring readline in /home/keith/.rvm/src/readline-6.2.
Compiling readline in /home/keith/.rvm/src/readline-6.2.
Installing readline to /home/keith/.rvm/usr

$ sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libxslt1-dev' instead of 'libxslt-dev'
Note, selecting 'libncurses5-dev' instead of 'ncurses-dev'
autoconf is already the newest version.
automake is already the newest version.
bison is already the newest version.
build-essential is already the newest version.
curl is already the newest version.
git-core is already the newest version.
libc6-dev is already the newest version.
libncurses5-dev is already the newest version.
libreadline6 is already the newest version.
libreadline6-dev is already the newest version.
libreadline6-dev set to manually installed.
libsqlite3-0 is already the newest version.
libsqlite3-dev is already the newest version.
libssl-dev is already the newest version.
libtool is already the newest version.
libxml2-dev is already the newest version.
libxslt1-dev is already the newest version.
libyaml-dev is already the newest version.
openssl is already the newest version.
sqlite3 is already the newest version.
subversion is already the newest version.
zlib1g is already the newest version.
zlib1g-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

$ cd ~/.rvm/src/ruby-1.8.7-p352/ext/readline/

$ ruby extconf.rb --with-readline-dir=/usr
checking for tgetnum() in -lncurses... yes
checking for readline/readline.h... yes
checking for readline/history.h... yes
checking for readline() in -lreadline... yes
checking for rl_filename_completion_function()... yes
checking for rl_username_completion_function()... yes
checking for rl_completion_matches()... yes
checking for rl_deprep_term_function in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_completion_append_character in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_basic_word_break_characters in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_completer_word_break_characters in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_basic_quote_characters in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_completer_quote_characters in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_filename_quote_characters in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_attempted_completion_over in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_library_version in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_event_hook in stdio.h,readline/readline.h,readline/history.h... yes
checking for rl_cleanup_after_signal()... yes
checking for rl_clear_signals()... yes
checking for rl_vi_editing_mode()... yes
checking for rl_emacs_editing_mode()... yes
checking for replace_history_entry()... yes
checking for remove_history()... yes
creating Makefile

$ make
gcc -I. -I. -I/home/keith/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/i686-linux -I. -DHAVE_READLINE_READLINE_H -DHAVE_READLINE_HISTORY_H -DHAVE_RL_FILENAME_COMPLETION_FUNCTION -DHAVE_RL_USERNAME_COMPLETION_FUNCTION -DHAVE_RL_COMPLETION_MATCHES -DHAVE_RL_DEPREP_TERM_FUNCTION -DHAVE_RL_COMPLETION_APPEND_CHARACTER -DHAVE_RL_BASIC_WORD_BREAK_CHARACTERS -DHAVE_RL_COMPLETER_WORD_BREAK_CHARACTERS -DHAVE_RL_BASIC_QUOTE_CHARACTERS -DHAVE_RL_COMPLETER_QUOTE_CHARACTERS -DHAVE_RL_FILENAME_QUOTE_CHARACTERS -DHAVE_RL_ATTEMPTED_COMPLETION_OVER -DHAVE_RL_LIBRARY_VERSION -DHAVE_RL_EVENT_HOOK -DHAVE_RL_CLEANUP_AFTER_SIGNAL -DHAVE_RL_CLEAR_SIGNALS -DHAVE_RL_VI_EDITING_MODE -DHAVE_RL_EMACS_EDITING_MODE -DHAVE_REPLACE_HISTORY_ENTRY -DHAVE_REMOVE_HISTORY -I/usr/include  -D_FILE_OFFSET_BITS=64  -fPIC -g -O2  -fPIC   -c readline.c
gcc -shared -o readline.so readline.o -L. -L/home/keith/.rvm/rubies/ruby-1.8.7-p352/lib -Wl,-R/home/keith/.rvm/rubies/ruby-1.8.7-p352/lib -L/usr/lib -Wl,-R/usr/lib -L.  -rdynamic -Wl,-export-dynamic    -Wl,-R -Wl,/home/keith/.rvm/rubies/ruby-1.8.7-p352/lib -L/home/keith/.rvm/rubies/ruby-1.8.7-p352/lib -lruby -lreadline -lncurses  -lrt -ldl -lcrypt -lm   -lc

$ make install
/usr/bin/install -c -m 0755 readline.so /home/keith/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/site_ruby/1.8/i686-linux

$ irb
ruby-1.8.7-p352 :001 > p 1
1
 => nil 
ruby-1.8.7-p352 :002 > $   

$ rvm remove 1.8.7
Removing /home/keith/.rvm/src/ruby-1.8.7-p352...
Removing /home/keith/.rvm/rubies/ruby-1.8.7-p352...
Removing ruby-1.8.7-p352 aliases...
Removing ruby-1.8.7-p352 wrappers...
Removing ruby-1.8.7-p352 environments...
Removing ruby-1.8.7-p352 binaries...

$ rvm install 1.8.7 --with-readline-dir=/usr
Installing Ruby from source to: /home/keith/.rvm/rubies/ruby-1.8.7-p352, this may take a while depending on your cpu(s)...

ruby-1.8.7-p352 - #fetching 
ruby-1.8.7-p352 - #extracting ruby-1.8.7-p352 to /home/keith/.rvm/src/ruby-1.8.7-p352
ruby-1.8.7-p352 - #extracted to /home/keith/.rvm/src/ruby-1.8.7-p352
Applying patch 'stdout-rouge-fix' (located at /home/keith/.rvm/patches/ruby/1.8.7/stdout-rouge-fix.patch)
ruby-1.8.7-p352 - #configuring 
ruby-1.8.7-p352 - #compiling 
ruby-1.8.7-p352 - #installing 
Removing old Rubygems files...
Installing rubygems-1.8.10 for ruby-1.8.7-p352 ...
Installation of rubygems completed successfully.
ruby-1.8.7-p352 - adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-1.8.7-p352 - #importing default gemsets (/home/keith/.rvm/gemsets/)
Install of ruby-1.8.7-p352 - #complete 

$ irb
1.8.7 :001 > p "hello world"
"hello world"
 => nil 
1.8.7 :002 > ^[[A^[[A^[[A^[[A^[[A

因此,总而言之,如果一些明亮的火花能建议我如何调试和解决这种情况,我将非常感激。

ps - 是的,我已经“谷歌”这个问题死了....

【问题讨论】:

  • 是的,我已经在 rvm 中尝试过这个补丁:github.com/wayneeseguin/rvm/issues/553
  • 向我们展示您的语言环境/键盘布局
  • 你试过1.9.3吗?我按照您的指示进行操作,并且能够使 readline 历史记录正常工作。现在,您实际上有助于指出正确的库“libreadline-dev”。
  • Sweet Jebus,我多年来一直在努力解决这个问题(以前的解决方案似乎不起作用),这次它为我做到了。干杯!

标签: ruby ubuntu rvm readline libreadline


【解决方案1】:

这里的 Ubuntu 12.04:这里的答案有帮助,但也具有误导性。

如果您使用的是 Ubuntu 12.04,请不要 pkg install readline,无论是否使用 --skip-autoreconf。完成此操作后,无论您为 rvm install 1.9.3 提供何种开关组合,readline 或 zlib 都将被破坏。

要让它工作,请执行rvm requirements 告诉您执行的apt-get install,执行pkg uninstall readline,然后执行简单的rvm remove 1.9.3; rvm install 1.9.3

【讨论】:

  • 我尝试解决这个问题超过 1 小时。应用您的解决方案后,一切都开始正常工作。非常感谢!!!
  • Ubuntu 12.04 也在这里。多次尝试此页面上的所有内容,然后是您的解决方案。仍然无法正常工作,我对此感到生气。所以我打算在 virtualbox 中设置一台新机器。
  • 在我尝试了所有其他方法之后,这也对我有用。原来我错过了不止几个要求。
  • 我在 12.10 中遇到了类似的问题,这解决了它。我跳过了pkg uninstall readline,我不确定它在 Ubuntu 中会做什么
  • “pkg uninstall readline”我认为他的意思是“rvm pkg uninstall readline”。话虽如此,我也跳过了它,删除/安装仍然为我解决了 13.04 的问题。
【解决方案2】:

我在 Ubuntu 11.10 上遇到了同样的问题。

如果我使用以下内容,readline 似乎可以正确编译:

$ rvm --skip-autoreconf pkg install readline

http://beginrescueend.com/packages/readline/底部所述

但是,当我调用 irb 时,我会收到正常错误“无法要求 readline”

最后,根据 Shane 的命令行,我调用了以下内容:

$ rvm install 1.9.3 --with-readline-dir=$rvm_usr_path --with-iconv-dir=$rvm_usr_path --with-zlib-dir=$rvm_usr_path --with-openssl-dir=$rvm_usr_path

而不是http://beginrescueend.com/packages/readline/中提到的命令

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

就我而言,1.9.3 版是我想要的。 终于irb想出了一个正常的readline。

感谢大家为我指明正确的方向。

【讨论】:

    【解决方案3】:

    好的,所以这似乎很明显,当你知道答案时总是这样:

    我放弃了使用 RVM,转而使用 rbenv - 我很高兴我做到了!

    sudo apt-get install libreadline-gplv2-dev
    CONFIGURE_OPTS="--with-readline-dir=/usr/include/readline --with-openssl-dir=/usr/local" rbenv-install 1.9.2-p290
    

    这个安装没有错误 - 我仍然不相信我需要 gplv2 包,因为我已经安装了 libreadline6-dev。然而,这仍然没有解决我的问题。它确实从等式中删除了 RVM,并告诉我,尽管我尽了最大努力,但 IRB shell 拒绝使用 readline。

    答案来自阅读这个伟大的指南:

    RubyTools.pdf

    在我发现的 ~/.irbrc 文件中:

    IRB.conf[:USE_READLINE] = false
    

    快速更新:

    IRB.conf[:USE_READLINE] = true
    

    我正在用煤气做饭!!

    感谢所有出色的答案和建议,非常感谢您的宝贵时间。

    【讨论】:

      【解决方案4】:

      这解决了我使用 Ruby 1.9.3 的 rvm 问题

      gem install rb-readline
      

      【讨论】:

      • 使用 Ubuntu 12.04,这就是我需要做的。在我的 ~/.irbrc 中也有以下内容,但不确定是否需要:require 'irb/ext/save-history' #History configuration IRB.conf[:SAVE_HISTORY] = 100 IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history" IRB.conf[:USE_READLINE] = true
      【解决方案5】:

      我遇到了同样的问题,但我在 11.04 并且阅读了您提供的链接 https://github.com/wayneeseguin/rvm/issues/553 并从 peplins 评论中的信息中删除了此处添加的 autoreconf 调用
      https://github.com/wayneeseguin/rvm/commit/94c301d 现在 readline 编译没有任何错误。在再次安装 ruby​​ 之前,我在编译 readline 之后重新添加了 autoreconf 调用。

      这就是我的工作方式:

      编辑 ~/.rvm/scripts/functions/pkg 并删除以下内容:

      if [[ "${rvm_skip_autoreconf_flag:-0}" == 0 ]] &&
        which autoreconf >/dev/null 2>&1 &&
        which libtoolize >/dev/null 2>&1 &&
        [[ -f configure.ac || -f configure.in ]]
      then
      __rvm_run "$package/autoreconf" \
        "autoreconf -is --force" \
        "Prepare $package in $rvm_src_path/$package-$version."
      fi
      

      编译 readline 并删除 ruby​​(我使用了 ree_dependencies 命令,但我不确定这是否必要):

      rvm pkg install ree_dependencies
      rvm remove 1.9.2
      

      撤消对 ~/.rvm/scripts/functions/pkg 的删除
      然后我用这个命令安装了 1.9.2(同样是来自 ree 安装,我不确定是否有必要,但这是我使用的)

      rvm install 1.9.2 --with-readline-dir=$rvm_usr_path --with-iconv-dir=$rvm_usr_path --with-zlib-dir=$rvm_usr_path --with-openssl-dir=$rvm_usr_path
      

      现在似乎一切正常,希望对某人有所帮助。

      【讨论】:

      • 您可以使用~/.rvm/scripts/functions/pkg,而不是编辑~/.rvm/scripts/functions/pkg
      【解决方案6】:

      我的设置是 ubuntu 11.10、RVM 1.10.2、ruby 1.9.3。

      这个 readline 问题在运行 irb 时出错,并且由于该错误而阻止了 rails 控制台的运行:

      'require': 无法加载此类文件 -- readline (LoadError)

      对我有用的解决方案是 Bryan Larsen 描述的解决方案,即

      不要 pkg install readline,有或没有 --skip-autoreconf

      按照 rvm 要求执行的 apt-get 安装,然后

      rvm --skip-autoreconf pkg uninstall readline

      rvm 移除 1.9.3

      rvm 安装 1.9.3

      谢谢布莱恩的小费。

      【讨论】:

        【解决方案7】:

        这些步骤解决了我之前编译 ruby​​ 后的问题(在 Lubuntu 12.04 上),并且在我运行时不断收到“compile readline missing”错误:

        sudo aptitude install build-essential openssl libreadline6 \
                              libreadline6-dev curl git-core zlib1g zlib1g-dev \
                              libssl-dev libyaml-dev libsqlite3-dev sqlite3 \
                              libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev \
                              automake libtool bison subversion
        rvm pkg uninstall readline
        rvm remove 1.9.3
        rvm install 1.9.3
        

        【讨论】:

          【解决方案8】:

          不幸的是,这些都不适合我。我最终使用了来自http://beginrescueend.com/packages/readline/的快速修复

          这解决了我的问题。

          【讨论】:

            【解决方案9】:

            您可以尝试安装包 libreadline5-dev 的解决方法。 我猜 libreadline6-dev 现在不工作了。

            【讨论】:

              【解决方案10】:

              对我来说,最新版本的 rvm 开箱即用。我的步骤

              bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
              

              根据rvm requirements

              apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
              
              rvm install 1.9.3
              
              rvm
              

              【讨论】:

                【解决方案11】:

                忘掉你听到的关于任何逻辑的一切,只要看看这里,一步一步地做同样的事情:

                  (ubuntu x64):
                
                 $ ruby extconf.rb 
                checking for tgetnum() in -lncurses... yes
                checking for readline/readline.h... yes
                checking for readline/history.h... yes
                checking for readline() in -lreadline... no
                checking for readline() in -ledit... no
                checking for editline/readline.h... no
                
                $ sudo aptitude install libedit-dev
                ..
                
                $ ruby extconf.rb
                checking for tgetnum() in -lncurses... yes
                checking for readline/readline.h... yes
                checking for readline/history.h... yes
                checking for readline() in -lreadline... no
                checking for readline() in -ledit... yes
                checking for rl_getc_function() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_filename_completion_function() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_username_completion_function() in stdio.h,readline/readline.h,readline/history.h... no
                checking for rl_completion_matches() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_refresh_line() in stdio.h,readline/readline.h,readline/history.h... no
                checking for rl_deprep_term_function in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_completion_append_character in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_basic_word_break_characters in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_completer_word_break_characters in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_basic_quote_characters in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_completer_quote_characters in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_filename_quote_characters in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_attempted_completion_over in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_library_version in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_editing_mode in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_line_buffer in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_point in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_event_hook in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_catch_sigwinch in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_catch_signals in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_cleanup_after_signal() in stdio.h,readline/readline.h,readline/history.h... no
                checking for rl_clear_signals() in stdio.h,readline/readline.h,readline/history.h... no
                checking for rl_set_screen_size() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_get_screen_size() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_vi_editing_mode() in stdio.h,readline/readline.h,readline/history.h... no
                checking for rl_emacs_editing_mode() in stdio.h,readline/readline.h,readline/history.h... no
                checking for replace_history_entry() in stdio.h,readline/readline.h,readline/history.h... no
                checking for remove_history() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for clear_history() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for RL_PROMPT_START_IGNORE in stdio.h,readline/readline.h,readline/history.h... yes
                checking for RL_PROMPT_END_IGNORE in stdio.h,readline/readline.h,readline/history.h... yes
                creating Makefile
                

                反正缺少太多的功能,但是...做下一个

                $ rvm pkg uninstall readline
                ...
                ╰─○ ruby extconf.rb                                                    
                checking for tgetnum() in -lncurses... yes
                checking for readline/readline.h... yes
                checking for readline/history.h... yes
                checking for readline() in -lreadline... yes
                checking for rl_getc_function() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_filename_completion_function() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_username_completion_function() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_completion_matches() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_refresh_line() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_deprep_term_function in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_completion_append_character in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_basic_word_break_characters in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_completer_word_break_characters in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_basic_quote_characters in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_completer_quote_characters in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_filename_quote_characters in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_attempted_completion_over in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_library_version in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_editing_mode in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_line_buffer in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_point in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_event_hook in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_catch_sigwinch in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_catch_signals in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_cleanup_after_signal() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_clear_signals() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_set_screen_size() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_get_screen_size() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_vi_editing_mode() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for rl_emacs_editing_mode() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for replace_history_entry() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for remove_history() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for clear_history() in stdio.h,readline/readline.h,readline/history.h... yes
                checking for RL_PROMPT_START_IGNORE in stdio.h,readline/readline.h,readline/history.h... yes
                checking for RL_PROMPT_END_IGNORE in stdio.h,readline/readline.h,readline/history.h... yes
                creating Makefile
                $ make
                compiling readline.c
                linking shared-object readline.so
                $ make install
                /usr/bin/install -c -m 0755 readline.so /home/sky/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/x86_64-linux
                installing default readline libraries
                
                
                
                irb
                1.9.3-p194 :001 > 
                

                你可以看到它对我来说很好。

                1 - 不要忘记安装 libedit-dev

                # dpkg --get-selections| egrep '(readline|libedit)'
                libedit-dev                                     install # <= BSD PACKAGE, not GNU, but... it is work fine to me
                libedit2                                        install # the same story as previous
                libreadline-dev                                 install
                libreadline5                                    install
                libreadline6                                    install
                libreadline6-dev                                install
                readline-common                                 install
                

                2 - 卸载 pkg readline

                $ rvm pkg uninstall readline
                

                3 - 转到 $rvm_path/src/ruby-#{version}/ext/readline 并执行

                $ ruby extconf.rb; make; make install
                

                4 - 忘记头痛

                【讨论】:

                  【解决方案12】:

                  如果您使用的是Bundler,那么以下可能会有所帮助:

                  echo "gem 'rb-readline'" >> Gemfile
                  bundle install
                  

                  【讨论】:

                    猜你喜欢
                    • 2012-01-29
                    • 1970-01-01
                    • 2012-02-22
                    • 1970-01-01
                    • 2011-12-30
                    • 2011-12-19
                    • 1970-01-01
                    • 1970-01-01
                    • 1970-01-01
                    相关资源
                    最近更新 更多