【问题标题】:Ruby undefined local variable byebugRuby 未定义的局部变量 byebug
【发布时间】:2015-09-22 02:28:55
【问题描述】:

我正在我的 rails 项目中执行文件 app.rb 并尝试使用 byebug gem 单步执行它,但我收到一条错误消息,提示“byebug”是一个未定义的局部变量。我正在使用命令“ruby app.rb”运行代码。通过命令行以这种方式执行 ruby​​ 文件时,是否有不同的方式来单步执行它?

    $ bundle install
Fetching gem metadata from https://rubygems.org/.....
Resolving dependencies...
Using byebug 6.0.2
Installing pg 0.18.3
Using bundler 1.6.2
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
$ ruby app.rb
app.rb:17:in `block in <main>': undefined local variable or method `byebug' for main:Object (NameError)
    from app.rb:15:in `glob'
    from app.rb:15:in `<main>'

【问题讨论】:

    标签: ruby debugging byebug


    【解决方案1】:

    看来我只需要在我的app.rb 文件顶部添加require "byebug"

    【讨论】:

      【解决方案2】:

      另一个调试选项是debugger gem:

      require 'debugger'; debugger
      

      https://github.com/cldwalker/debugger

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-03-29
        • 2013-04-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多