没有这样的文件加载 - readline

Jay*_*Jay 39 ruby ruby-on-rails

我收到以下错误:

$script/console
Loading development environment (Rails 2.2.2)
/opt/ruby-enterprise-1.8.6-20080709/lib/ruby/1.8/irb/completion.rb:10:in `require': no such file to load -- readline (LoadError)
Run Code Online (Sandbox Code Playgroud)

我在哪里可以获取该文件以及它应该进入哪个目录?

谢谢!

Sté*_*hen 46

readline模块通常是Ruby包本身的一部分.

您是否手动构建了Ruby安装?如果是这样,您需要确保安装了libreadline及其标头,然后重新构建.

在Debian/Ubuntu上:

apt-get install libreadline-dev
Run Code Online (Sandbox Code Playgroud)

或者在RHEL/CentOS上,试试吧

yum install readline-devel
Run Code Online (Sandbox Code Playgroud)

更新:

您使用的是Ubuntu的旧版本.如果要继续使用它,请/etc/apt/sources.list在文本编辑器中打开,并将所有出现的内容更改archive.ubuntu.comold-releases.ubuntu.com.然后,apt-get update再次运行并尝试上述操作.

不过,我恳请您考虑更新您的安装.Ubuntu 7.10在很长一段时间内没有看到安全更新,不推荐在生产中使用它.即使它不是生产机器,由于某些库/依赖项的旧版本,您很可能会遇到进一步的问题.


小智 31

您需要安装ncurses和readline库.

在Ubunutu你可以做到

sudo apt-get install libreadline5-dev libncurses5-dev
Run Code Online (Sandbox Code Playgroud)

然后你将不得不重新编译你的ruby源附带的readline

cd <ruby-src-dir>/ext/readline
ruby extconf.rb
make
sudo make install
Run Code Online (Sandbox Code Playgroud)

如果您使用RVM,您可以这样做

rvm package install readline
Run Code Online (Sandbox Code Playgroud)

编辑:

在较新的RVM版本上,最后一个命令是

rvm pkg install readline
Run Code Online (Sandbox Code Playgroud)


bou*_*uby 10

这对我有用

gem 'rb-readline'
Run Code Online (Sandbox Code Playgroud)

并将以下行添加到您的Gemfile:

gem 'rb-readline'
Run Code Online (Sandbox Code Playgroud)

在ubuntu上使用rvm安装ruby 1.9.3中的类似问题/答案


Rub*_*der 6

这是解决这个问题的最简单方法,只需添加到您的Gemfile:

gem 'rb-readline'
Run Code Online (Sandbox Code Playgroud)

然后运行 bundle install