Skip to content

Commit f049eaa

Browse files
fix(desktop): don't regenerate bindings on a shipped debug build
A debug build runs export_generated() on startup to refresh the frontend's generated files. The write paths are the build machine's (CARGO_MANIFEST_DIR/../frontend/src/generated), so a debug build run from anywhere else — e.g. a portable folder on another machine — panicked on startup (the window flashed and vanished). Guard the regeneration on the source tree actually existing, so a shipped debug build just skips it. Release builds never ran this (it's cfg(debug_assertions)).
1 parent afa87d2 commit f049eaa

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src-tauri/src/lib.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,19 @@ pub fn run() {
151151
let builder = specta_builder();
152152

153153
// Regenerate the frontend's generated files on every debug build, so a Rust
154-
// type/default change fails `tsc` until the frontend is updated.
154+
// type/default change fails `tsc` until the frontend is updated. Guard on the
155+
// source tree existing: a shipped debug build (run from anywhere but the build
156+
// tree) has no `frontend/src/generated` to write to, and the export would panic
157+
// on startup — skip it there instead of crashing.
155158
#[cfg(debug_assertions)]
156-
export_generated();
159+
if std::path::Path::new(concat!(
160+
env!("CARGO_MANIFEST_DIR"),
161+
"/../frontend/src/generated"
162+
))
163+
.is_dir()
164+
{
165+
export_generated();
166+
}
157167

158168
#[allow(unused_mut)]
159169
let mut tb = tauri::Builder::default();

0 commit comments

Comments
 (0)