为什么Rails控制台说“无法加载这样的文件 - readline”?

时间:2013-04-01 21:32:19

标签: ruby ruby-on-rails-3.2 rails-console

我是Ruby on Rails的新手,并且正在使用RVM来管理Ruby版本。

我的笔记本电脑安装了Ruby1.8.7,但我的项目是使用RVM,Ruby1.9.3和Rails 3.2.11。

如果没有它,我无法运行rails crails console错误:

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

1 个答案:

答案 0 :(得分:11)

编译Ruby时需要安装readline库。

如果您使用的是CentOS / Redhat / Fedora Linux,请使用以下命令安装软件包:

sudo yum install readline-devel

或者,在Ubuntu上,使用:

sudo apt-get install libreadline6 libreadline6-dev

然后重新编译Ruby。