# Check if current file is "main" when debugging

**URL:** <https://discourse.julialang.org/t/check-if-current-file-is-main-when-debugging/73893>\
**Category:** New to Julia\
**Tags:** debug, vscode\
**Created:** [January 1, 2022, 12:15pm UTC](https://discourse.julialang.org/t/check-if-current-file-is-main-when-debugging/73893 "2022-01-01T12:15:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yue-Zhengyuan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yue-zhengyuan/32/220439_2.png) [@Yue-Zhengyuan](https://discourse.julialang.org/u/Yue-Zhengyuan)\
**Post date:** [January 1, 2022, 12:15pm UTC](https://discourse.julialang.org/t/check-if-current-file-is-main-when-debugging/73893/1 "2022-01-01T12:15:18Z")

</div>

In Julia documentation, [it is said that](https://docs.julialang.org/en/v1/manual/faq/#How-do-I-check-if-the-current-file-is-being-run-as-the-main-script?-1) to determine that a file is run as the main script, one can check if `abspath(PROGRAM_FILE) == @ __FILE__ ` is `true`. When directly running the file, this works fine. However, when debugging in VS Code using the Julia extension, the value of `PROGRAM_FILE ` changes to `/Users/my_user_name/.vscode/extensions/julialang.language-julia-1.5.8/scripts/debugger/run_debugger.jl`, i.e. the path to the debugger.

So my question is: how to check if the current file is “main” when debugging (in VS Code)?

Further information:

- OS: macOS Monterey 12.0.1 (21A559)
- VS Code: version 1.62.3 (Commit ccbaa2d27e38e5afa3e5c21c1c7bef4657064247)
- Julia installation: version 1.7.1
- Julia extension: version 1.5.8

---

<div class="post-metadata">

**Author:** ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)\
**Post date:** [January 2, 2022, 11:52am UTC](https://discourse.julialang.org/t/check-if-current-file-is-main-when-debugging/73893/2 "2022-01-02T11:52:30Z")

</div>

Seems like checking that run\_debugger.jl file could maybe give some clues, cause that file will likely need to know what file should be run. I’m on the phone so haven’t looked at it, but would be where I start.  
Maybe something that the vscode plug-in could fix by injecting the file you want run into whatever the @ **FILE** uses in the background.

---

<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:** [January 3, 2022, 9:14am UTC](https://discourse.julialang.org/t/check-if-current-file-is-main-when-debugging/73893/3 "2022-01-03T09:14:56Z")

</div>

Probably best to fix this in the extension:  
[https://github.com/julia-vscode/julia-vscode/issues/2661](https://github.com/julia-vscode/julia-vscode/issues/2661)
