# Debugging a module using VS code debugger

**URL:** <https://discourse.julialang.org/t/debugging-a-module-using-vs-code-debugger/72426>\
**Category:** VS Code\
**Tags:** question\
**Created:** [December 2, 2021, 4:34am UTC](https://discourse.julialang.org/t/debugging-a-module-using-vs-code-debugger/72426 "2021-12-02T04:34:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhalonen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bhalonen/32/9848_2.png) [@bhalonen](https://discourse.julialang.org/u/bhalonen)\
**Post date:** [December 2, 2021, 4:34am UTC](https://discourse.julialang.org/t/debugging-a-module-using-vs-code-debugger/72426/1 "2021-12-02T04:34:40Z")

</div>

I’m attempting to debug a module by running my “runtests.jl” file with the run and debug button on the left ribbon. Everything runs alright, but it ignores any breakpoints I’ve put in the module.

Does the breakpoints work if you include the code through a using statement?

Am I using this type of debugger correctly?

---

<div class="post-metadata">

**Author:** ![bhalonen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bhalonen/32/9848_2.png) [@bhalonen](https://discourse.julialang.org/u/bhalonen)\
**Post date:** [December 2, 2021, 6:23pm UTC](https://discourse.julialang.org/t/debugging-a-module-using-vs-code-debugger/72426/2 "2021-12-02T18:23:46Z")

</div>

I tried using Debugger.jl as well, and find that it passes over my breakpoints set in there as well. Do you need to have all code being debugged in a single file?

---

<div class="post-metadata">

**Author:** ![bhalonen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bhalonen/32/9848_2.png) [@bhalonen](https://discourse.julialang.org/u/bhalonen)\
**Post date:** [December 2, 2021, 6:27pm UTC](https://discourse.julialang.org/t/debugging-a-module-using-vs-code-debugger/72426/3 "2021-12-02T18:27:46Z")

</div>

I want to run basically.

```julia
@enter include("my_script.jl")

```

Is this not a good way to run it?

---

<div class="post-metadata">

**Author:** ![bhalonen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bhalonen/32/9848_2.png) [@bhalonen](https://discourse.julialang.org/u/bhalonen)\
**Post date:** [December 2, 2021, 6:30pm UTC](https://discourse.julialang.org/t/debugging-a-module-using-vs-code-debugger/72426/4 "2021-12-02T18:30:05Z")

</div>

Ok, figured it out. some reason it doesn’t really work if you don’t call the function explcitly. So just

```julia
include("set_stuff_up.jl")
@enter run_your_function(args...)

```

is the way to do it using Debugger.jl. Still not sure how to do it using VS Code.

---

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [December 2, 2021, 6:34pm UTC](https://discourse.julialang.org/t/debugging-a-module-using-vs-code-debugger/72426/5 "2021-12-02T18:34:06Z")

</div>

`include` is special, so I’m not surprised that it can’t be the entrypoint. VSCode’s debugger supports `@enter` from the integrated REPL, give it a try!

---

<div class="post-metadata">

**Author:** ![bhalonen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bhalonen/32/9848_2.png) [@bhalonen](https://discourse.julialang.org/u/bhalonen)\
**Post date:** [December 2, 2021, 6:57pm UTC](https://discourse.julialang.org/t/debugging-a-module-using-vs-code-debugger/72426/6 "2021-12-02T18:57:11Z")

</div>

Yeah, just spent a few hours wanting to.

```julia
@enter include("test/runtests.jl")

```

Then I started stepping into that function and I realize it might be not such a good idea.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [December 2, 2021, 7:00pm UTC](https://discourse.julialang.org/t/debugging-a-module-using-vs-code-debugger/72426/7 "2021-12-02T19:00:24Z")

</div>

Packages used via `using`/`import` should always work fine with Debugger.jl/VS Code when `@enter`/`@run`ing a function defined in the package.

That said, VS Code should be able to simply step through your runtests.jl, but it’s possible something along the way is being compiled. Try clearing the list of compiled function/modules in the debugger pane.

---

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [December 2, 2021, 8:54pm UTC](https://discourse.julialang.org/t/debugging-a-module-using-vs-code-debugger/72426/8 "2021-12-02T20:54:17Z")

</div>

Related discussion:

> [@VSCode Debugger not hitting breakpoint in include file](https://discourse.julialang.org/t/vscode-debugger-not-hitting-breakpoint-in-include-file/46014):
>
> If I set a breakpoint in an included file, the breakpoint is not getting hit. Below shows my setup. I simply click the debug button to run test1.jl, the debugger runs and never stops at the break point. Running Julia 1.5.0 and VS Code extension is 1.0.6 Am I doing something wrong? I think this used to work

---

<div class="post-metadata">

**Author:** ![senhalil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/senhalil/32/42473_2.png) [@senhalil](https://discourse.julialang.org/u/senhalil)\
**Post date:** [February 12, 2024, 7:51pm UTC](https://discourse.julialang.org/t/debugging-a-module-using-vs-code-debugger/72426/9 "2024-02-12T19:51:52Z")

</div>

We run our tests by including them in the runtest.jl file. (Is this an anti-pattern?)

And because of the explanations above we cannot debug our test sets.

What is the correct approach to debug tests via vscode debugger?
