# How to debug a script in existing REPL using VSCode

**URL:** <https://discourse.julialang.org/t/how-to-debug-a-script-in-existing-repl-using-vscode/60822>\
**Category:** VS Code\
**Tags:** vscode\
**Created:** [May 9, 2021, 12:45pm UTC](https://discourse.julialang.org/t/how-to-debug-a-script-in-existing-repl-using-vscode/60822 "2021-05-09T12:45:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RGerzaguet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rgerzaguet/32/45492_2.png) [@RGerzaguet](https://discourse.julialang.org/u/RGerzaguet)\
**Post date:** [May 9, 2021, 12:45pm UTC](https://discourse.julialang.org/t/how-to-debug-a-script-in-existing-repl-using-vscode/60822/1 "2021-05-09T12:45:42Z")

</div>

Hello all,

I often use VSCode when I want to debug code and I conversely put breakpoints into functions and call the functions in my Julia session (in the REPL) using the macro `@run myFunc(x)` (or even `@enter`). This works perfectly well by the way.

But this approach does not work if I put breakpoints in a script (for instance in a for loop) and not in a function. I tried `@run include("myScript.jl")` without success.  
It does however works if I use the command `Julia: Debug file in a new process` [but the issue here is that it launches a fresh Julia session which takes way more time than reusing the REPL.]

So what is the magic command to have script _and_ debugger with REPL ?

Thanks in advance 🙂

---

<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:** [May 10, 2021, 6:27am UTC](https://discourse.julialang.org/t/how-to-debug-a-script-in-existing-repl-using-vscode/60822/2 "2021-05-10T06:27:11Z")

</div>

There is none, currently. It’s possible to implement `@run` for top-level blocks instead of only for function calls though.

---

<div class="post-metadata">

**Author:** ![RGerzaguet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rgerzaguet/32/45492_2.png) [@RGerzaguet](https://discourse.julialang.org/u/RGerzaguet)\
**Post date:** [May 10, 2021, 1:49pm UTC](https://discourse.julialang.org/t/how-to-debug-a-script-in-existing-repl-using-vscode/60822/3 "2021-05-10T13:49:46Z")

</div>

Ok many thanks for the quick reply and the opened issue on VSCode side ([https://github.com/julia-vscode/julia-vscode/issues/2146](https://github.com/julia-vscode/julia-vscode/issues/2146)) !

---

<div class="post-metadata">

**Author:** ![filchristou](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/filchristou/32/26760_2.png) [@filchristou](https://discourse.julialang.org/u/filchristou)\
**Post date:** [August 4, 2022, 9:17am UTC](https://discourse.julialang.org/t/how-to-debug-a-script-in-existing-repl-using-vscode/60822/4 "2022-08-04T09:17:42Z")

</div>

> currently. It’s possible to implement `@run` for top-level blocks

how is this implemented ? are the top-level blocks just wrapped into a function ?

I am asking because I would like be able to debug files directly from the REPL.  
The use case is for the `./test/*` files.
