2

I'm executing the file app.rb in my rails project and trying to step through it using the byebug gem, but I get an error saying 'byebug' is an undefined local variable. I'm running the code using the command 'ruby app.rb'. Is there a different way to step through a ruby file when executing it this way via the command line?

    $ 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>'
user2974739
  • 619
  • 1
  • 7
  • 20

2 Answers2

5

Looks like I just had to add require "byebug" at the top my app.rb file.

Thomas Klemm
  • 10,678
  • 1
  • 51
  • 54
user2974739
  • 619
  • 1
  • 7
  • 20
0

Another debugging option is the debugger gem:

require 'debugger'; debugger

https://github.com/cldwalker/debugger

Leo Brito
  • 2,053
  • 13
  • 20