{"record":{"id":"218e2e4716a0ebcd","repo":"herdrdev/herdr","slug":"failed-to-inspect-remote-binary-env-var-path","errorCode":null,"errorMessage":"failed to inspect {REMOTE_BINARY_ENV_VAR} path {}: {err}","messagePattern":"failed to inspect (.+?) path (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/remote/attach.rs","lineNumber":905,"sourceCode":"fn remote_binary_exists(ssh: &RemoteSsh, remote_herdr: &RemoteHerdr) -> io::Result<bool> {\n    let command = format!(\"test -x {}\", remote_herdr.shell_path);\n    Ok(ssh.sh_output(&command)?.status.success())\n}\n\nfn remote_binary_override_path() -> io::Result<Option<PathBuf>> {\n    let Some(value) = std::env::var_os(REMOTE_BINARY_ENV_VAR) else {\n        return Ok(None);\n    };\n    if value.is_empty() {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidInput,\n            format!(\"{REMOTE_BINARY_ENV_VAR} must not be empty\"),\n        ));\n    }\n\n    let path = PathBuf::from(value);\n    let metadata = fs::metadata(&path).map_err(|err| {\n        io::Error::new(\n            err.kind(),\n            format!(\n                \"failed to inspect {REMOTE_BINARY_ENV_VAR} path {}: {err}\",\n                path.display()\n            ),\n        )\n    })?;\n    if !metadata.is_file() {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidInput,\n            format!(\n                \"{REMOTE_BINARY_ENV_VAR} path is not a file: {}\",\n                path.display()\n            ),\n        ));\n    }\n\n    Ok(Some(path))","sourceCodeStart":887,"sourceCodeEnd":923,"githubUrl":"https://github.com/herdrdev/herdr/blob/f457cff4f2648eee85d176f8a41861241d4e8428/src/remote/attach.rs#L887-L923","documentation":"This error is thrown when the code cannot stat the path pointed to by the HERDR_REMOTE_BINARY environment variable (REMOTE_BINARY_ENV_VAR). The fs::metadata call failed and the underlying OS error kind is preserved. It means the configured remote binary path is inaccessible, does not exist, or has permission problems.","triggerScenarios":"Setting HERDR_REMOTE_BINARY to a path that does not exist on the local machine, a path inside a directory without execute/search permission, a broken symlink, or a path on an unmounted filesystem, then invoking remote attach.","commonSituations":"Typo in the env var value, pointing at a path that only exists on the remote host rather than locally, stale path after the binary was moved or deleted, or a symlink whose target is missing.","solutions":["Verify the path exists and is readable: ls -l \"$HERDR_REMOTE_BINARY\"","Point HERDR_REMOTE_BINARY at an absolute path to the local herdr binary that actually exists","Check directory traversal permissions on every component of the path","Unset the variable to let herdr auto-detect or download the remote binary"],"exampleFix":"# before\nexport HERDR_REMOTE_BINARY=/opt/herdr/bin/herdr  # does not exist\n# after\nexport HERDR_REMOTE_BINARY=/usr/local/bin/herdr  # verify with: ls -l /usr/local/bin/herdr","handlingStrategy":"validation","validationCode":"use std::path::Path;\n\nfn remote_binary_ok(p: &str) -> bool {\n    let path = Path::new(p);\n    !p.is_empty()\n        && std::fs::metadata(path)\n            .map(|m| m.is_file())\n            .unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match run_attach() {\n    Err(e) if e.kind() == std::io::ErrorKind::NotFound => eprintln!(\"HERDR_REMOTE_BINARY path missing: check the path\"),\n    r => r,\n}","preventionTips":["Set HERDR_REMOTE_BINARY only to verified absolute file paths","Add a startup check that stats the path before invoking remote attach"],"tags":["environment-variable","filesystem","remote-attach","rust"],"backgroundTag":"invalid-env-var-path","analyzedSha":"f457cff4f2648eee85d176f8a41861241d4e8428","analyzedAt":"2026-08-28T15:41:09.197Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}