From a50217a5ca3a67a843486d5a3dd0bda5db6ed6ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Koz=C3=A1k?= Date: Wed, 5 Aug 2026 18:42:23 +0200 Subject: [PATCH] fix: emit the test binary where the debugger can actually find it `std::env::current_dir()` inside the wasm sandbox is not the project directory, so the absolute path handed to the debug adapter did not match where zig wrote the binary. Use a path relative to the build task's cwd. Also drop the UUID from the name. The extension has no post-session hook, so every debug run left another `zig_test_` executable behind in the project root; a fixed name is overwritten instead of accumulating. --- src/zig.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/zig.rs b/src/zig.rs index 76087bf..0216ef3 100644 --- a/src/zig.rs +++ b/src/zig.rs @@ -300,12 +300,20 @@ fn get_project_name(task: &zed::TaskTemplate) -> Option { } fn get_test_exe_path() -> Option { - let test_exe_dir = std::env::current_dir().ok()?; - let mut name = format!("{}_{}", ZIG_TEST_EXE_BASENAME, uuid::Uuid::new_v4()); + // Relative to the build task's cwd (the worktree root): `std::env::current_dir()` + // inside the wasm sandbox is not the project directory, so the absolute path it + // produced pointed somewhere the emitted binary never ended up. + // + // A fixed name rather than a UUID, because the extension has no hook that runs + // after the debug session ends, so nothing can ever delete these binaries. One + // file that gets overwritten beats an unbounded pile of them in the project root. + // It is not placed under `.zig-cache/` or `zig-out/` because zig does not create + // a missing output directory and would fail the build on a fresh checkout. + let mut name = format!(".{ZIG_TEST_EXE_BASENAME}"); if zed::current_platform().0 == zed::Os::Windows { name.push_str(".exe"); } - Some(test_exe_dir.join(name).to_string_lossy().into_owned()) + Some(name) } zed::register_extension!(ZigExtension);