rustdesk/rustdesk · error
Failed to resolve current executable path: {}
Error message
Failed to resolve current executable path: {} What it means
current_exe_canonical_path resolves the current process executable via std::env::current_exe() and then canonicalizes it. This error wraps a failure of current_exe() itself into an anyhow error; callers use the result to verify that a peer IPC process (portable service / logon helper) is the expected executable.
Source
Thrown at src/ipc/auth.rs:293
fd,
libc::SOL_SOCKET,
libc::SO_PEERCRED,
&mut cred as *mut _ as *mut libc::c_void,
&mut len,
)
};
if rc == 0 {
Some(cred)
} else {
None
}
}
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))]
#[inline]
fn current_exe_canonical_path() -> ResultType<PathBuf> {
let current = std::env::current_exe()
.map_err(|err| anyhow::anyhow!("Failed to resolve current executable path: {}", err))?;
fs::canonicalize(¤t).map_err(|err| {
anyhow::anyhow!(
"Failed to canonicalize current executable path '{}': {}",
current.display(),
err
)
.into()
})
}
#[cfg(target_os = "linux")]
#[inline]
fn peer_exe_canonical_path_by_pid(peer_pid: u32) -> ResultType<PathBuf> {
let proc_exe = PathBuf::from(format!("/proc/{peer_pid}/exe"));
let peer_exe = fs::read_link(&proc_exe).map_err(|err| {
anyhow::anyhow!(
"Failed to read peer executable link '{}': {}",
proc_exe.display(),View on GitHub (pinned to 91c9fccbb0)
Solutions
- Ensure the running executable file is not deleted/renamed in place; use atomic install (write new file, rename over old) for updates.
- Reproduce the raw std::env::current_exe() error and fix the launch environment (check /proc/self/exe on Linux, GetModuleFileName on Windows).
- Cache the canonical exe path at process start before any update procedure can touch the binary.
- If verification of a peer is failing, also check the peer's PID is still alive - the same helper reports peer-path errors.
Example fix
// before
let current = std::env::current_exe()
.map_err(|err| anyhow::anyhow!("Failed to resolve current executable path: {}", err))?;
// after (fail fast at startup, before peers are spawned)
let exe_path = std::env::current_exe()
.map_err(|err| anyhow::anyhow!("Failed to resolve current executable path: {}", err))?;
let exe_path = fs::canonicalize(&exe_path)?; // done once in main, reused for peer verification Defensive patterns
Strategy: fallback
Validate before calling
fn exe_path_available() -> bool {
std::env::current_exe().is_ok()
} Try / catch
match current_exe_canonical_path() {
Ok(p) => verify_peer_against(p),
Err(e) => {
log::error!("cannot verify peer executable: {e}; denying IPC connection");
// fail closed: treat verification as failed rather than allowing
}
} Prevention
- Use atomic updates (rename over) so the running executable file is never deleted in place.
- Resolve and cache the canonical exe path once at process start.
- Keep peer-verification fail-closed: a resolution error should deny, not allow, the IPC peer.
When it happens
Trigger: Calling windows_portable_service_ipc_allows_logon_helper_executable or ensure_peer_executable_matches_current_by_pid when std::env::current_exe() fails - e.g. the executable path cannot be determined by the OS, the binary was deleted/renamed while running, or /proc self-exe resolution fails on Linux.
Common situations: Binary deleted or replaced after launch (update-in-place) while the process still runs; running under an environment where the executable image cannot be queried; heavily sandboxed runtime deleting its own image.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Failed to canonicalize current executable path '{}': {}
- Failed to canonicalize peer executable path '{}': {}
- invalid reply
- File {} already exists
- can't parse filepath:{}
AI-assisted analysis of rustdesk/rustdesk@91c9fccbb0 (2026-09-10).
Data as JSON: /api/errors/b3b8739cc3e34f3e.
Report an issue: GitHub.