Rails rails c 问题求解

Jsiguo · 2011年12月02日 · 最后由 credochen 回复于 2013年09月01日 · 7727 次阅读

ubuntu 11.10 rails 3.1.3 控制台输入 rails c 一直报

/home/gsm/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/completion.rb:9:in `require': cannot load such file -- readline (LoadError) 
from /home/gsm/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/irb/completion.rb:9:in `<top (required)>' 
from /home/gsm/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/commands/console.rb:3:in `require' 
from /home/gsm/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/commands/console.rb:3:in `<top (required)>' 
from /home/gsm/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/commands.rb:37:in `require' 
from /home/gsm/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/commands.rb:37:in `<top (required)>' 
from script/rails:6:in `require' 
from script/rails:6:in `<main>' 

Bash 代码

sudo apt-get install libncurses5-dev libreadline5-dev 

但是实践发现 libreadline5-dev 已经废弃了 “现在没有可用的软件包 libreadline5-dev,但是它被其它的软件包引用了。 这可能意味着这个缺失的软件包可能已被废弃, 或者只能在其他发布源中找到 可是下列软件包取代了它: libreadline-gplv2-dev:i386 lib64readline-gplv2-dev:i386 libreadline-gplv2-dev E: 软件包 libreadline5-dev 没有可供安装的候选者”

参考步骤 2 - 用 RVM 安装 Ruby 环境

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

仍然无法解决 有谁知道怎么解决啊???

我记得以前用 Ubuntu 的时候,通过安装 ruby-full 来安装系统 ruby 以及相关的所有依赖包,你试试看,然后重新编译一次 ruby?

sudo apt-get install ruby-full

Google 了一下,ruby-full 包含了对 libreadline-ruby 的依赖,可能会解决你的问题。 http://packages.ubuntu.com/hardy/ruby-full

rvm 安装完后,没有仔细看 rvm 的 info. 里面有 ubuntu 下 build ruby 需要的所有依赖包。一条命令就安装完毕了。

一般这种情况下,我一般的解决办法是 uninstall,clean,安装依赖包 然后再 install 一下。一定要 clean.

刚执行了

sudo apt-get install ruby-full
cd ~/.rvm/src/ruby-1.9.3-p0/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... no
checking for readline() in -ledit... no
checking for editline/readline.h... no”
make install

出现“make: 没有什么可以做的为 `install'。”

rails c 的问题仍没解决 等待中。。。。。

前几天开始使用 rvm 后遇到过你这个问题,好在记录下来了,分享一下:

rvm pkg install openssl (older format - rvm package install openssl)
rvm pkg install iconv (older format - rvm package install iconv)
rvm pkg install readline(rails console缺少的lib)
rvm remove 1.9.3
rvm install 1.9.3 -C --with-openssl-dir=\$HOME/.rvm/usr,--with-iconv-dir=\$HOME/.rvm/usr, --with-readline-6.2-dir=\$HOME/.rvm/usr 
rvm 1.9.3 --default

提供问题解决链接: http://stackoverflow.com/questions/5487507/rails3-and-readline-problem

5 废掉了用 6

$ sudo apt-get install libreadline6-dev 

感谢 6 楼的朋友 问题顺利解决了呵呵

不客气..我是菜鸟啊..互相学习!! 哈哈..

用 6 楼方法装 readline 和 iconv 报错,不能 rails console http://ruby-china.org/topics/996 同问

iconv 错误 [2012-02-02 19:54:34] autoreconf -is --force configure.ac:134: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body ../../lib/autoconf/lang.m4:194: AC_LANG_CONFTEST is expanded from... ../../lib/autoconf/general.m4:2591: _AC_COMPILE_IFELSE is expanded from... ../../lib/autoconf/general.m4:2607: AC_COMPILE_IFELSE is expanded from... ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... configure.ac:134: the top level configure.ac:134: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body ../../lib/autoconf/lang.m4:194: AC_LANG_CONFTEST is expanded from... ../../lib/autoconf/general.m4:2591: _AC_COMPILE_IFELSE is expanded from... ../../lib/autoconf/general.m4:2607: AC_COMPILE_IFELSE is expanded from... ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... configure.ac:134: the top level libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, build-aux'. libtoolize: linking filebuild-aux/config.guess' libtoolize: linking file build-aux/config.sub' libtoolize: linking filebuild-aux/install-sh' libtoolize: linking file build-aux/ltmain.sh' libtoolize: Consider addingAC_CONFIG_MACRO_DIR([m4])' to configure.ac and libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree. libtoolize: Consider adding -I m4' to ACLOCAL_AMFLAGS in Makefile.am. libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR,../build-aux'. libtoolize: linking file ../build-aux/config.guess' libtoolize: linking file../build-aux/config.sub' libtoolize: linking file ../build-aux/install-sh' libtoolize: linking file../build-aux/ltmain.sh' libtoolize: Consider adding AC_CONFIG_MACRO_DIR([m4])' to configure.ac and libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree. libtoolize: Consider adding-I m4' to ACLOCAL_AMFLAGS in Makefile.am. autoreconf: configure.ac: AM_GNU_GETTEXT is used, but not AM_GNU_GETTEXT_VERSION libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, build-aux'. libtoolize: linking filebuild-aux/config.guess' libtoolize: linking file build-aux/config.sub' libtoolize: linking filebuild-aux/install-sh' libtoolize: linking file build-aux/ltmain.sh' libtoolize: Consider addingAC_CONFIG_MACRO_DIR([m4])' to configure.ac and libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree. libtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am. configure.ac:134: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body ../../lib/autoconf/lang.m4:194: AC_LANG_CONFTEST is expanded from... ../../lib/autoconf/general.m4:2591: _AC_COMPILE_IFELSE is expanded from... ../../lib/autoconf/general.m4:2607: AC_COMPILE_IFELSE is expanded from... ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... configure.ac:134: the top level configure.ac:134: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body ../../lib/autoconf/lang.m4:194: AC_LANG_CONFTEST is expanded from... ../../lib/autoconf/general.m4:2591: _AC_COMPILE_IFELSE is expanded from... ../../lib/autoconf/general.m4:2607: AC_COMPILE_IFELSE is expanded from... ../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from... ../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from... ../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from... configure.ac:134: the top level configure.ac:151: error: possibly undefined macro: AC_EILSEQ If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation. autoreconf: /usr/bin/autoconf failed with exit status: 1

readline 错误

[2012-02-02 19:59:52] 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

rvm requierment

源码包里面有各种 ext lib,编译时没装过的话,apt-get install xxx 后,进入 ruby 源码包找到对应的 xxx,然后 ruby mkconfig,make make install 就行,不用重编译 ruby 的

sudo apt-get install libreadline6 libreadline6-dev 再到 ruby 源码里安装 readline 就可以了。 我也遇到过。

rvm pkg install readline 之后重装 ruby

#3 楼 @Saito 强调一下 saito 的经验,以前我也老被这种事郁闷,不过从某个版本开始,rvm 会提示你要安装的 c 库了,提示很清晰,直接列出你要在 ubuntu 上运行的命令,很有参考价值,所以强烈建议认真看看 rvm 输出的各种信息

Ubuntu 的库更新不够快,Arch 装新版一点压力都没有

17 楼 +1

同样遇到这个问题了,可以通过如下方式解决: 先安装 readline,命令如下: apt-get install libreadline6-dev 再进入到 ruby 源码中,重新编译 readline,命令如下:

cd ~/.rvm/src/ruby-1.9.3-p0/ext/readline
ruby extconf.rb  
make  
sudo make install  

就可以了

15 楼正解

fedora 安装也没遇到压力。

@superbatironmans5 rvm pkg install autoconf # 可能需要 sudo apt-get remove autoconf; sudo apt-get purge autoconf rvm pkg install readline # 可能需要 rvm pkg install ncurses rvm reinstall 1.9.3 --with-readline-dir=$RVM_HOME/usr # 可能需要 --with-ncurses-dir=$RVM_HOME/usr rvm use 1.9.3 --default 我是大概这么个过程。 用 UBUNTU 10.04 没遇这问题

#19 楼 @xiongbo 多谢,顺利解决了!

需要 登录 后方可回复, 如果你还没有账号请 注册新账号