M
Modular•6mo ago
obadakhalili

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
artemiogr97
artemiogr97•6mo ago
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"
obadakhalili
obadakhalili•6mo ago
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 CLI
artemiogr97
artemiogr97•6mo ago
yeah, I'm testing on my side, seems like the -I argument is being ignored
obadakhalili
obadakhalili•6mo ago
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%20program
Debugging | Modular Docs
Debugging Mojo programs.
artemiogr97
artemiogr97•6mo ago
True, so I don't know it there is a way to add some path
obadakhalili
obadakhalili•6mo ago
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
artemiogr97
artemiogr97•6mo ago
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 comma
ModularBot
ModularBot•6mo ago
Congrats @artemiogr97, you just advanced to level 2!
artemiogr97
artemiogr97•6mo ago
I guess there is an equivalent environment variable for the "stable" build
obadakhalili
obadakhalili•6mo ago
hmm, there should be a more straightforward way ..
artemiogr97
artemiogr97•6mo ago
I guess so, let's wait for someone's answer 🙂
obadakhalili
obadakhalili•6mo ago
sure. thanks for your time though
ModularBot
ModularBot•6mo ago
Congrats @obadakhalili, you just advanced to level 1!
Josiah
Josiah•5mo ago
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.
ModularBot
ModularBot•5mo ago
Congrats @jokellum, you just advanced to level 1!
Want results from more Discord servers?
Add your server