{"record":{"id":"46b4ffa6280b5dcc","repo":"herdrdev/herdr","slug":"failed-to-create-private-herdr-remote-download-dir","errorCode":null,"errorMessage":"failed to create private herdr remote download directory","messagePattern":"failed to create private herdr remote download directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/remote/attach.rs","lineNumber":1574,"sourceCode":"}\n\nfn private_download_dir(asset_key: &str) -> io::Result<PathBuf> {\n    let base = crate::platform::remote_private_temp_base();\n    fs::create_dir_all(&base)?;\n    for attempt in 0..100 {\n        let dir = base.join(format!(\n            \"herdr-remote-{}-{}-{attempt}\",\n            std::process::id(),\n            asset_key\n        ));\n        match crate::platform::create_remote_private_dir(&dir) {\n            Ok(()) => return Ok(dir),\n            Err(err) if err.kind() == io::ErrorKind::AlreadyExists => continue,\n            Err(err) => return Err(err),\n        }\n    }\n\n    Err(io::Error::new(\n        io::ErrorKind::AlreadyExists,\n        \"failed to create private herdr remote download directory\",\n    ))\n}\n\nfn confirm_remote_install(\n    target: &str,\n    remote_herdr: &RemoteHerdr,\n    source_description: &str,\n) -> io::Result<()> {\n    if !io::stdin().is_terminal() {\n        return Err(io::Error::other(format!(\n            \"matching remote herdr {} is not installed at {}; run from an interactive terminal to approve installation\",\n            current_version(),\n            remote_herdr.shell_path\n        )));\n    }\n","sourceCodeStart":1556,"sourceCodeEnd":1592,"githubUrl":"https://github.com/herdrdev/herdr/blob/f457cff4f2648eee85d176f8a41861241d4e8428/src/remote/attach.rs#L1556-L1592","documentation":"Herdr creates a private temp download directory by retrying create_dir with random names, treating AlreadyExists as a retry signal. If retries exhaust with the directory still colliding (or a final attempt returns AlreadyExists), this AlreadyExists error is surfaced, meaning it could not obtain a unique private directory.","triggerScenarios":"Extremely unlikely random-name collisions, a hostile or full tmpfs where every create returns AlreadyExists, or a tampered TMPDIR pointing at a read-only/existing structure causing repeated AlreadyExists results.","commonSituations":"TMPDIR misconfigured to a weird path, /tmp exhausted or replaced, or test environments looping creation.","solutions":["Set TMPDIR to a clean writable directory and retry","Free space / repair /tmp if it is full or corrupted","Check permissions on the temp directory root"],"exampleFix":"# before\nexport TMPDIR=/nonexistent_or_full_dir\n# after\nexport TMPDIR=/tmp && herdr remote attach ...","handlingStrategy":"fallback","validationCode":"let tmp = std::env::temp_dir();\nif std::fs::metadata(&tmp).map(|m| m.is_dir()).unwrap_or(false) {\n    // writable temp root available\n}","typeGuard":null,"tryCatchPattern":"match create_private_download_dir() {\n    Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => {\n        std::fs::create_dir_all(std::env::temp_dir().join(\"herdr-dl\"))\n    }\n    r => r,\n}","preventionTips":["Set TMPDIR to a known writable location in constrained environments","Monitor /tmp capacity on hosts running herdr"],"tags":["filesystem","temp-dir","tmpdir","rust"],"backgroundTag":"temp-directory-creation-failed","analyzedSha":"f457cff4f2648eee85d176f8a41861241d4e8428","analyzedAt":"2026-08-28T15:41:09.197Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}