当我尝试在 3.1 中加载 Rails 控制台时出错

发布于 2024-12-03 21:37:56 字数 862 浏览 1 评论 0原文

当我尝试在 3.1 中加载 Rails 控制台时,出现以下错误。为什么我会得到这个?我做错了什么吗?

/home/brettlee/.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/brettlee/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/completion.rb:9:in `<top (required)>'
from /home/brettlee/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0/lib/rails/commands/console.rb:3:in `require'
from /home/brettlee/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0/lib/rails/commands/console.rb:3:in `<top (required)>'
from /home/brettlee/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0/lib/rails/commands.rb:37:in `require'
from /home/brettlee/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0/lib/rails/commands.rb:37:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

I get the following error when i try to load the rails console in 3.1. why do i get this? am i doing something wrong?

/home/brettlee/.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/brettlee/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/completion.rb:9:in `<top (required)>'
from /home/brettlee/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0/lib/rails/commands/console.rb:3:in `require'
from /home/brettlee/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0/lib/rails/commands/console.rb:3:in `<top (required)>'
from /home/brettlee/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0/lib/rails/commands.rb:37:in `require'
from /home/brettlee/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.0/lib/rails/commands.rb:37:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦初启 2024-12-10 21:37:56

编辑:布莱恩是对的 - 只需尝试安装 libncurses &首先是 libreadline,它很有可能自行工作。如果这不起作用,您可能需要重新安装整个 ruby​​。

非常常见的错误 - 这意味着您缺少一些运行控制台所需的库。

本指南应该向您展示如何修复它。

缺点是,尝试安装 libncurses & readline 使用以下命令(我从你的目录结构猜测你正在使用 Ubuntu。如果它是其他不使用 apt-get 的东西,请进行相应更改)

sudo apt-get install libncurses5-dev libreadline5-dev
ruby ~/.rvm/src/ruby-1.9.2-p290/readline/ext/extconf.rb
cd ~/.rvm/src/ruby-1.9.2-p290/readline/ext/
sudo make

如果这不起作用,你需要重新安装 ruby 1.9.2 安装readline包后通过rvm。不过,不要卸载通过 apt-get 安装的 libncurses/readline 软件包 - 你仍然需要它们。

rvm package install readline
rvm remove 1.9.2
rvm install 1.9.2 --with-readline-dir=$rvm_path/usr
ruby ~/.rvm/src/ruby-1.9.2-p290/readline/ext/extconf.rb
cd ~/.rvm/src/ruby-1.9.2-p290/readline/ext/
sudo make

希望这有帮助

EDIT: Bryan is right - just try installing libncurses & libreadline first, there's a good chance that'll work by itself. If that doesn't fly, you might need to do the whole ruby reinstall thing.

Really common error - it means you're missing some libraries necessary to run console.

This guide should show you how to fix it.

The short of it is, try installing libncurses & readline with the following command (I'm guessing from your directory structure you're using Ubuntu. If it's something else that doesn't use apt-get, change accordingy)

sudo apt-get install libncurses5-dev libreadline5-dev
ruby ~/.rvm/src/ruby-1.9.2-p290/readline/ext/extconf.rb
cd ~/.rvm/src/ruby-1.9.2-p290/readline/ext/
sudo make

If that doesn't work, you'll need to reinstall ruby 1.9.2 through rvm after installing the readline package. Don't uninstall the libncurses/readline packages installed through apt-get though - you'll still need 'em.

rvm package install readline
rvm remove 1.9.2
rvm install 1.9.2 --with-readline-dir=$rvm_path/usr
ruby ~/.rvm/src/ruby-1.9.2-p290/readline/ext/extconf.rb
cd ~/.rvm/src/ruby-1.9.2-p290/readline/ext/
sudo make

Hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文