Application_root_dir() has different result when debugging in VSCode + LLDB?


Hi everyone,

application_root_dir() retrieves the root direction, if possible, based on the environment variable CARGO_MANIFEST_DIR. Cargo sets this automatically to your crate root, so that config/asset locating works correctly from the get go.

I’m trying to debug my game running VSCode + RLS + LLDB. Apparently going through that launch path does not set CARGO_MANIFEST_DIR, resulting in application_root_dir() returning the target/debug folder in my crate folder. As a result, config and asset loading doesn’t work.

VSCode is a rather popular IDE for Rust at the moment, so I can’t be the only one who ran into this problem. How have others solved this? Are people symlinking assets into the target folder as a pre-build step? Adding CARGO_MANIFSET_DIR to their launch.json? Am I simply missing something?

(Azriel Hoh) #2


When debugging, I tend to set CARGO_MANIFEST_DIR manually on the debug launch options. I think it’s best to keep the CARGO_MANIFEST_DIR variable as the “development time flag” than to change application_root_dir() to cleverly detect if it’s inside a development workspace.

1 Like

Alright thanks!

Forgot to reply to this myself, but that’s the solution I eventually ended up with myself as well. Good to know it’s what others do too, gives newcomers like me the confidence we’re not doing something weird.