Rails控制台错误:加载〜/ .pryrc时出错:命令:未找到`continue`

时间:2014-05-05 21:33:36

标签: ruby ruby-on-rails-4 rails-console pry-rails

当我在当前笔记本电脑上使用rails控制台时(在任何rails项目上),当控制台启动时出现以下错误。

Rails console error: Error loading ~/.pryrc: Command: `continue` not found

控制台仍然可以正常加载和操作,但我似乎无法找出错误的原因。

以下是.pryrc的内容。

Pry.config.pager = false
Pry.config.color = true
Pry.commands.alias_command 'c', 'continue'
Pry.commands.alias_command 's', 'step'
Pry.commands.alias_command 'n', 'next'

如果我删除第三行并运行rails控制台,则会出现类似错误,引用' step'代替。该错误不会影响我排除故障的能力,但我真的很想了解潜在的问题。

2 个答案:

答案 0 :(得分:6)

我不认为这些命令是默认的pry。尝试安装pry-dubugger

gem install pry-debugger

然后修改为:

if defined?(PryDebugger)
  Pry.commands.alias_command 'c', 'continue'
  Pry.commands.alias_command 's', 'step'
  Pry.commands.alias_command 'n', 'next'
  Pry.commands.alias_command 'f', 'finish'
end

请参阅pry-debugger docs

答案 1 :(得分:0)

对我有用的是安装pry-nav gem:

gem install pry-nav
- 或者 - 在Gemfile中使用gem "pry-nav"

.pryrc

Pry.commands.alias_command 'c', 'continue' rescue nil
Pry.commands.alias_command 's', 'step' rescue nil
Pry.commands.alias_command 'n', 'next' rescue nil
Pry.commands.alias_command 'f', 'finish' rescue nil
Pry.commands.alias_command 'r!', 'reload!' rescue nil