Import modules from sibling directory

Hi, how do i pass the directory of -I <dir> in mojo run:

  1. to the mojo LSP in VSCode?
    the mojo.lsp.includeDirs is greyed out when I try to use it. Is it disabled or not implemented yet?

  2. to launch.json when debug?
    Is there an environment variable MOJOPATH for this similar to PYTHONPATH?

Thanks

$ pwd
/path/to/src
$ ls
foo  main
$ tree
.
├── foo
│   ├── foo.mojo
│   └── __init__.mojo
└── main
    └── main.mojo

$ pixi run mojo run -I . main/main.mojo 
main
foo
$ 

macOS: 12.7.6 (21H1320)
VSCode: 1.103.0 (Universal)
Identifier: modular-mojotools.vscode-mojo
Version: 25.5.0
Last Updated: 2025-08-08, 05:29:42

For the LSP, you can have a look at the install instructions of some packages, e.g. Installation – Larecs🌲

For the run configuration I do not have a nice solution. For run, I often use the internal console. For debug I defined a build task that executes mojo build and set this as a prerequisite of the run. This works somewhat well, though it clutters the workspace with the built executables.

I am currently afk but could post my scripts tomorrow. Would be curious to see if others have better solutions. I really think this would be a great native feature to have for the vscode extension.

1 Like