# Add debugger on the last line?

**URL:** <https://forum.crystal-lang.org/t/add-debugger-on-the-last-line/4983>\
**Category:** Help & Support\
**Created:** [September 30, 2022, 12:53pm UTC](https://forum.crystal-lang.org/t/add-debugger-on-the-last-line/4983 "2022-09-30T12:53:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zw963](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/zw963/32/1623_2.png) [@zw963](https://forum.crystal-lang.org/u/zw963)\
**Post date:** [September 30, 2022, 12:53pm UTC](https://forum.crystal-lang.org/t/add-debugger-on-the-last-line/4983/1 "2022-09-30T12:53:09Z")

</div>

```crystal
# 1.cr
x = 100
debugger

```

```nohighlight
 ╰─ $ cr i 1.cr 
From: /home/zw963/Crystal/share/crystal/src/kernel.cr:517:19 <Program>#exit:

    512: 
    513: # Terminates execution immediately, returning the given status code
    514: # to the invoking environment.
    515: #
    516: # Registered `at_exit` procs are executed.
 => 517: def exit(status = 0) : NoReturn
    518: status = Crystal::AtExitHandlers.run status
    519: Crystal.ignore_stdio_errors { STDOUT.flush }
    520: Crystal.ignore_stdio_errors { STDERR.flush }
    521: Process.exit(status)
    522: end

pry(exit)> x
error in line 1
Error: undefined local variable or method 'x' for top-level

Did you mean 'p'?
pry(exit)> 

```

---

<div class="post-metadata">

**Author:** ![asterite](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/asterite/32/60_2.png) [@asterite](https://forum.crystal-lang.org/u/asterite)\
**Post date:** [September 30, 2022, 1:26pm UTC](https://forum.crystal-lang.org/t/add-debugger-on-the-last-line/4983/2 "2022-09-30T13:26:44Z")

</div>

Right, there’s no easy way to fix this. It’s the same if you use Ruby’s binding.pry

My workaround is to put some code after debugger.
