Debugging Issue with Mojo's VSCode Debugger
I have a file
./foo/bar.mojo
that imports a package in ./
, so to run it I have to use the CLI path argument (-I
) as follows: mojo build -I . ./foo/bar.mojo
.
The problem occurs when I try to debug the file with Mojo's VSCode debugger, getting the error message unable to locate module 'x'
, the same error message that throws if I try to run bar.mojo
without the path argument, so it seems like the problem is that I have to specify the path argument for the debugger too. I tried to update the launch file configuration by setting the args
property to "args": ["-I", "../"]
, which does show up in the final command but still doesn't work throwing the same error message.29 Replies
I guess you need to add "." Instead of "..", normally in vscode relative paths are resolved from your working dir
The offer option is to set the working dir to be "./foo"
I have actually tried
"."
too but it didin't work. the other option, "./foo"
, didn't work as well
there is the possibility that it isn't taking the -I
argument in the first place, as this is a different binary with different CLIyeah, I'm testing on my side, seems like the -I argument is being ignored
actually, it shouldn't work. re-reading the docs, the
args
property defines the set of arguments passed to your Mojo program you are trying to debug
https://docs.modular.com/mojo/tools/debugging#:~:text=Any%20command%2Dline%20arguments%20to%20be%20passed%20to%20the%20programDebugging | Modular Docs
Debugging Mojo programs.
True, so I don't know it there is a way to add some path
there must be because what I'm actually trying to do is debug one of Basalt's (https://github.com/basalt-org/basalt) examples. so I think it is safe to assume that its team found a way to do this
If you are using the nightly build I guess you can do what is mentioned here https://discord.com/channels/1087530497313357884/1226262582629892106
Basically you have the variable environment variable
MODULAR_MOJO_NIGHTLY_IMPORT_PATH
in which you can define all your import paths separated by a commaCongrats @artemiogr97, you just advanced to level 2!
I guess there is an equivalent environment variable for the "stable" build
hmm, there should be a more straightforward way ..
I guess so, let's wait for someone's answer 🙂
sure. thanks for your time though
Congrats @obadakhalili, you just advanced to level 1!
Stumbled on here also. Kind of looking for a PYTHON_PATHS env var. I'm also trying to use basalt as a thirdparty package with vscode. The launch.json doesnt work for me either
Its nice they have a package API to transport stuff, but since mojo is super young, and the packages are super new, being able to import them in "develop" mode would be valuable.
Congrats @jokellum, you just advanced to level 1!