Can't get VScode to generate a executable

hi, i need some help setting vscode.
afaik my rust toolchain is working as both rustc and cargo are working from command line

so i installed the rust analyzer and codelldb on vscode
but when i try to use either run or run without debugging from from it i get a error saying that it can't find the executable file. there is no other errors or messages that i can see

if i make a executable with rustc and copy it to where it expect the executable to be as specified in launch.json, it will run it.
but have tried multiple different configurations on launch.json, and followed every guide i found internet. but i can't make it create a executable

Can you share your launch.json and the rough project structure?

btw, using ctrl+shift+p and using rust analizer:Debug or just hovering the mouse on main and clicking run does work.

is the run menu options that have problems.

and there is no project. is just a single .rs file with hello world.
even though i did try to make cargo to make a project and ran the hellow world it makes as default but it didn't change anything

when comes to the launch.json i tried everything. the default it creates itself
the ones from multiple guides like:

and at least 10 others, but the forum will only let me put 2 links per post.

i even delved into the codelldb documentation and used its minimal launch.json while tried other commands on it to see if at least i would get a different result. but no avail.

tbh i don't see it doing anything the looks that it attempted to do anything related to building or compiling when picking options from the run menu.

maybe im just misunderstanding something? is my first time with vscode as well.

EDIT: also if i set the launch parameter to the exe that it creates when i run it with the run/debug option it shows above main, it will run it when i pick the options from run menu or press F5, and even stop on the breakpoints. but it will not create it if the file is not there already.

well i solved the issue, so decided to put the explanation if someone with the issue searches and ends here.

it was mostly a bit of bad luck that for some reason the first default launch.json it created did not work at the time and at some point i broke something somewhere and nothing was working anymore. i don't know what actually happened there, but it got fixed mysteriously as it happened.

and my fault for not understanding that the debugging environment only debugs, you can set the launch.json to call the things to do the build for you. but it still needs to be done at some point and its not its job. that's why it needs to be pointed at the executable directly.

and in all fairness none of the guides i started with elaborated much on what was going on (some were straight up wrong or skipping steps).
if i eventually came across one that actually did a good job of explaining things, by then i was already past the point i was paying proper attention, my bad.

but right now as long i properly cargo the project and point vscode to the directory, it will generate a default launch.json that works

1 Like