bevy: Unable to run bevy application via VSCode debug UI
Bevy version
0.5.0
Operating system & version
Windows 10 Pro Build 19043.1110
What you did
- Followed first time set up using: https://bevyengine.org/learn/book/getting-started/setup/
- Set
rustflags = ["-Zshare-generics=off"]
in.cargo/config.toml
as per the following issue: https://github.com/bevyengine/bevy/issues/1126#issuecomment-750000945 - Build via terminal command:
cargo build
- Create the following
.vscode/launch.config
:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/target/debug/game-test.exe", // Adjust exe name appropriately on your machine
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"console": "internalConsole"
}
],
}
- Create the following
src/main.rs
:
use bevy::prelude::*; // The presence of this line triggers the issue
fn main() {
println!("hello world!");
}
- Attempt to run using the VSCode Debugger UI, selecting the launch configuration we created above
What you expected to happen
Starting the executable via cppvsdbg debugger in VSCode should complete successfully with no error.
What actually happened
The following error is reported in Debug Console:
The program '[10184] game-test.exe' has exited with code -1073741515 (0xc0000135).
It seems like the application terminates early due to missing modules.
I opened Process Monitor whilst running the application via VSCode debug to see what binaries were getting linked into the application. It seems that the following file is missing under all search paths: std-92c1680604aea3a5.dll
.
So I ran again, this time using cargo run
, which I know works fine. This time, the missing dll was correctly found at:
<path\to\user>\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\std-92c1680604aea3a5.dll
.
So this suggests that my .vscode/launch.json
is missing some vital pathing to the toolchain target std lib.
My rust and cargo knowledge is extremely limited, as is my vscode knowledge to be fair. If I were to guess, I would say that the launch configuration is not providing enough pathing information to the loading binary, whereas cargo run does provide this. So I think there may be a missing step in the Bevy docs to get debugging working - I’m just not sure what it is yet.
Anyone else able to repro this?
Additional information
Running the application via cargo run
works fine - in fact, it should be noted that I can get started learning Bevy using this method, however, I’d very much like to get debugging working.
Manually running the executable from CMD or by double clicking the exe yields the following error:
Manually running from the VSCode terminal yields nothing (actually I think maybe the stdout is routed somewhere weird, so best not to read too much into that).
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 17 (4 by maintainers)
coming at you from 2023 where this is still an issue and the only documentation is a single comment on a bug!
I think we could add this to the Bevy book Setup page or perhaps https://bevyengine.org/learn/book/troubleshooting/
If anyone else using CodeLLDB, the environment syntax is a little different, something like this
Good suggestion.
${home}
is not valid (at least on Windows) but you can straight up reference environment variables using the windows syntax.So I have been able to get it to work by adding the following to my
launch.json
:I wonder if we can also get hold of the rust toolchain target as a variable…
EDIT - Included
;${workspaceFolder}/target/debug/deps
in addition to the toolchain dir@afonsolage Yeah, I agree. Ok I am happy to close this issue to keep the Bevy tracker clean. I’ll take it up with vscode-cpptools next.