{"record":{"id":"2812d023be2a7831","repo":"nikivdev/code","slug":"binary-not-found","errorCode":null,"errorMessage":"binary '{}' not found","messagePattern":"binary '(.+?)' not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/daemon.rs","lineNumber":550,"sourceCode":"    if expanded.exists() {\n        return Ok(expanded);\n    }\n\n    // Try to find on PATH using `which`\n    let output = Command::new(\"which\")\n        .arg(name)\n        .output()\n        .with_context(|| format!(\"failed to find binary '{}'\", name))?;\n\n    if output.status.success() {\n        let path_str = String::from_utf8_lossy(&output.stdout);\n        let path = PathBuf::from(path_str.trim());\n        if path.exists() {\n            return Ok(path);\n        }\n    }\n\n    bail!(\"binary '{}' not found\", name)\n}\n\n/// Check if a health endpoint is responding.\nfn check_health(url: &str) -> bool {\n    let client = Client::builder()\n        .timeout(Duration::from_millis(750))\n        .build();\n\n    let Ok(client) = client else {\n        return false;\n    };\n\n    client\n        .get(url)\n        .send()\n        .and_then(|resp| resp.error_for_status())\n        .map(|_| true)\n        .unwrap_or(false)","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/daemon.rs#L532-L568","documentation":"find_binary in src/daemon.rs resolves the daemon executable by checking a list of candidate paths; if none of the candidates exists on disk it bails with `binary '<name>' not found`. It is raised while starting the daemon (start_daemon_inner), meaning the CLI cannot locate the daemon executable it needs to spawn.","triggerScenarios":"Calling start_daemon_inner when the daemon binary was never installed, was installed outside the searched PATH/candidate locations, the candidate string contains extra whitespace handled by trim but a stale path, or the binary was deleted/upgraded between installs.","commonSituations":"Installing the CLI via cargo but the daemon helper went to a non-PATH directory; PATH differing between shell and daemon-spawned subprocess; partial upgrade that removed the old binary before installing the new one; running inside a container image that only shipped the CLI.","solutions":["Locate/install the missing binary (e.g. reinstall the CLI or build the daemon component) and ensure it is on PATH.","Run `which <name>` in the same shell/environment to confirm it resolves; fix PATH if not.","Check the install prefix (e.g. ~/.local/bin, ~/.cargo/bin) is in PATH for the process starting the daemon.","Reinstall after a failed/partial upgrade so the binary exists again."],"exampleFix":"// before: binary not on PATH\n$ f daemon start  // bail!(\"binary 'myapp-daemon' not found\")\n// after: ensure PATH includes install dir\nexport PATH=\"$HOME/.local/bin:$PATH\"","handlingStrategy":"validation","validationCode":"// Rust: confirm the binary resolves before starting the daemon\nfn ensure_binary_on_path(name: &str) -> anyhow::Result<()> {\n    let found = std::process::Command::new(\"which\")\n        .arg(name)\n        .output()\n        .map(|o| o.status.success())\n        .unwrap_or(false);\n    anyhow::ensure!(found, \"{} must be installed and on PATH before starting the daemon\", name);\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match find_binary(\"myapp-daemon\") {\n    Ok(path) => start_daemon(&path),\n    Err(e) if e.to_string().contains(\"not found\") => {\n        eprintln!(\"Daemon binary missing — reinstall the CLI and ensure ~/.local/bin is on PATH.\");\n        std::process::exit(1);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Add the install prefix (~/.local/bin, ~/.cargo/bin) to PATH in shell profiles.","Reinstall the CLI after upgrades so helper binaries always exist.","In CI, cache the installed daemon binary or install it as a setup step.","Use absolute paths for daemon spawns where possible instead of PATH lookup."],"tags":["binary-not-found","daemon","path"],"backgroundTag":"binary-not-found","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}