{"record":{"id":"71a28dca88f4140d","repo":"facebook/flow","slug":"failed-to-get-executable-path","errorCode":null,"errorMessage":"failed to get executable path","messagePattern":"failed to get executable path","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust_port/crates/flow_common_build_id/src/lib.rs","lineNumber":18,"sourceCode":"/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nuse std::sync::OnceLock;\n\nuse flow_common_xx as xx;\n\nstatic BUILD_ID: OnceLock<String> = OnceLock::new();\n\npub fn get_build_id() -> String {\n    BUILD_ID\n        .get_or_init(|| {\n            let mut state = xx::State::new(0);\n            let executable = std::env::current_exe().expect(\"failed to get executable path\");\n            let contents = std::fs::read(&executable).unwrap_or_else(|err| {\n                panic!(\n                    \"failed to read executable at {} for flow build id: {}\",\n                    executable.display(),\n                    err\n                )\n            });\n            state.update(&contents);\n            let hash = format!(\"{:016x}\", state.digest());\n            hash\n        })\n        .clone()\n}\n","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/facebook/flow/blob/f88ac94bcf6992f5d5a158854d94613ebb92c6e6/rust_port/crates/flow_common_build_id/src/lib.rs#L1-L32","documentation":"To compute the client/server build id, flow hashes the bytes of its own executable; `std::env::current_exe().expect(\"failed to get executable path\")` panics when the OS cannot resolve the running binary's path. On Linux this resolves /proc/self/exe, so it fails when /proc is missing/restricted or when the binary file was deleted or replaced after the process started (the symlink then points to a deleted inode).","triggerScenarios":"The flow binary is overwritten or unlinked while running — in-place `cp` during deploys, a package manager upgrade replacing the binary, cargo rebuilding over a still-running binary; containers/chroots without /proc mounted; seccomp/sandbox policies blocking /proc/self/exe.","commonSituations":"A long-lived flow daemon surviving an upgrade that removed the old binary (its /proc/PID/exe shows `(deleted)`); deploy scripts that overwrite binaries in place; minimal container images with procfs masked.","solutions":["Restart the flow client/server after an upgrade so it runs the current binary path.","Change deploy scripts to install via rename (write new file, `mv` over) instead of overwriting the running binary in place.","Ensure /proc is mounted and /proc/self/exe is readable inside the container or sandbox.","As a code fix, fall back to argv[0] or a build-time embedded id when current_exe errors."],"exampleFix":"// before\nlet executable = std::env::current_exe().expect(\"failed to get executable path\");\n\n// after\nlet executable = std::env::current_exe().unwrap_or_else(|_| {\n    std::path::PathBuf::from(std::env::args_os().next().unwrap_or_default())\n});","handlingStrategy":"fallback","validationCode":"// Cheap pre-check where feasible: the exe path must resolve to an existing file\nfn exe_resolvable() -> bool {\n    std::env::current_exe().map(|p| p.exists()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"let executable = std::env::current_exe()\n    .unwrap_or_else(|_| std::path::PathBuf::from(std::env::args_os().next().unwrap_or_default()));","preventionTips":["Deploy binaries via rename/replace, never overwrite a running binary in place.","Restart long-lived flow processes after upgrades so current_exe resolves to a live file.","Ensure /proc is mounted and readable inside containers/sandboxes that run flow."],"tags":["build-id","current-exe","procfs","deploy"],"backgroundTag":"executable-not-found-in-path","analyzedSha":"f88ac94bcf6992f5d5a158854d94613ebb92c6e6","analyzedAt":"2026-08-20T10:41:37.992Z","contentChangedAt":"2026-08-20T10:41:37.992Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}