【问题标题】:Rails console error: Error loading ~/.pryrc: Command: `continue` not foundRails 控制台错误:加载时出错 ~/.pryrc:命令:找不到`continue`
【发布时间】:2014-06-22 08:01:37
【问题描述】:

当我在当前的笔记本电脑(在任何 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”。该错误不会影响我进行故障排除的能力,但我真的很想了解根本问题。

【问题讨论】:

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


    【解决方案1】:

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

    gem install pry-debugger
    

    然后修改为:

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

    pry-debugger docs

    【讨论】:

      【解决方案2】:

      对我有用的是安装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
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-11-30
        • 2014-08-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-01-21
        相关资源
        最近更新 更多