{"record":{"id":"e55972eac7d503ee","repo":"herdrdev/herdr","slug":"failed-to-determine-herdr-executable-path-err","errorCode":null,"errorMessage":"failed to determine herdr executable path: {err}","messagePattern":"failed to determine herdr executable path: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/server/autodetect.rs","lineNumber":191,"sourceCode":"}\n\n// ---------------------------------------------------------------------------\n// Server spawning\n// ---------------------------------------------------------------------------\n\n/// Spawns the herdr server as a background daemon process.\n///\n/// The server process is fully detached:\n/// - Runs in its own session (setsid) so it survives the client exiting\n/// - Stdin/stdout/stderr are redirected to /dev/null\n/// - Inherits relevant environment variables (`XDG_CONFIG_HOME`, `HERDR_SESSION`,\n///   socket overrides, etc.), except inherited socket overrides are cleared when\n///   this CLI invocation explicitly selected a session.\n///\n/// Returns the PID of the spawned server process.\npub fn spawn_server_daemon() -> io::Result<u32> {\n    let exe = std::env::current_exe().map_err(|err| {\n        io::Error::new(\n            err.kind(),\n            format!(\"failed to determine herdr executable path: {err}\"),\n        )\n    })?;\n\n    info!(exe = %exe.display(), \"spawning server daemon\");\n\n    let mut command = build_server_daemon_command(exe);\n\n    let pid =\n        crate::platform::launch_server_daemon_command(&mut command).map_err(|err: io::Error| {\n            io::Error::new(err.kind(), format!(\"failed to spawn herdr server: {err}\"))\n        })?;\n    info!(pid, \"server daemon spawned\");\n\n    Ok(pid)\n}\n","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/herdrdev/herdr/blob/f457cff4f2648eee85d176f8a41861241d4e8428/src/server/autodetect.rs#L173-L209","documentation":"spawn_server_daemon could not resolve the path of the currently running herdr executable via std::env::current_exe(). Without the executable path the daemon cannot re-spawn itself as a background server. The underlying OS error kind and message are preserved.","triggerScenarios":"std::env::current_exe() failing: the binary was deleted or replaced while running (common after `herdr update` overwriting the running binary on some platforms), /proc not mounted on Linux, or exec-path retrieval unsupported in the environment.","commonSituations":"Self-update replaced the binary mid-run, running from a deleted temp file, containers with restricted /proc, or unusual exec environments.","solutions":["Restart herdr from a stable, non-replaced binary location","If this happens right after an update, exit the old session and launch the new binary","Verify /proc is mounted (Linux) and the binary file still exists at its original path","Avoid deleting/replacing the herdr binary while sessions are running"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"let exe = std::env::current_exe().map(|p| p.to_path_buf()).ok();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid replacing the herdr binary while it runs","Pin a stable install location for the binary","Restart sessions after self-updates"],"tags":["executable-path","spawn","environment","self-update"],"backgroundTag":"current-exe-resolution-failed","analyzedSha":"f457cff4f2648eee85d176f8a41861241d4e8428","analyzedAt":"2026-08-28T15:41:09.197Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}