rails console - 没有要加载的文件 - readline(LoadError)[ubuntu 11.10]

时间:2012-02-11 16:53:17

标签: ruby-on-rails ruby ubuntu console readline

我是铁杆上的红宝石新手。当我使用命令: rails console 时,会出现问题:“没有要加载的文件 - readline(LoadError)

   /home/<username>/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/completion.rb:9:in `require': no such file to load -- readline (LoadError)
        from /home/<username>/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/completion.rb:9:in `<top (required)>'
        from /home/<username>/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/commands/console.rb:3:in `require'
        from /home/<username>/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/commands/console.rb:3:in `<top (required)>'
        from /home/<username>/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/commands.rb:38:in `require'
        from /home/<username>/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.1/lib/rails/commands.rb:38:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

所以我搜索了谷歌,并按照http://rails3blog.com/2010/09/error-no-such-file-to-load-readline-loaderror/进行了搜索,但它对我不起作用。

我的操作系统 Ubuntu 11.10 Ruby 1.9.2p290 Rails 3.2.1

PS:我已使用以下命令安装readline: rvm --skip-autoreconf pkg install readline。

PS:我经过长时间的搜索后解决了这个问题,答案如下:

1)确保您已安装ubuntus readline和editline开发包

sudo apt-get install libreadline6 libreadline6-dev

2)配置ruby的readline扩展以使用系统库,而不是rvm的包

rvm pkg uninstall readline
cd ~/.rvm/src/ruby-1.9.2-p290/ext/readline
ruby extconf.rb --with-editline-dir=/usr/ --with-readline-dir=/usr/
make
make install

3)转到您的项目并启动rails控制台

这是答案的链接:can't get "rails console" to work on ubuntu 11.10

1 个答案:

答案 0 :(得分:1)

以上错误指向 completion.rb

的第9行中 require'readline'语句

readline 库未在您的系统中正确安装。您可能需要在ubuntu中为它安装 libreadline-dev 包。

按照此StackOverflow question解决'没有此类文件加载 - readline '错误的方法。