{"record":{"id":"17c7ff55a51a1f29","repo":"warpdotdev/warp","slug":"failed-to-create-temp-file-prefix-e","errorCode":null,"errorMessage":"Failed to create temp file '{prefix}': {e}","messagePattern":"Failed to create temp file '(.+?)': (.+?)","errorType":"exception","errorClass":"AgentDriverError::ConfigBuildFailed","httpStatus":null,"severity":"error","filePath":"app/src/ai/agent_sdk/driver/harness/mod.rs","lineNumber":575,"sourceCode":"        .ok()\n        .flatten()\n}\n\n/// Create a [`NamedTempFile`] with the given prefix and write `content` into it.\n///\n/// Used by third-party harnesses to stage prompts / system prompts on disk\n/// before launching the CLI, avoiding shell-quoting issues with complex input.\npub(super) fn write_temp_file(\n    prefix: &str,\n    content: &str,\n    suffix: &str,\n) -> Result<NamedTempFile, AgentDriverError> {\n    let mut file = tempfile::Builder::new()\n        .prefix(prefix)\n        .suffix(suffix)\n        .tempfile()\n        .map_err(|e| {\n            AgentDriverError::ConfigBuildFailed(anyhow::anyhow!(\n                \"Failed to create temp file '{prefix}': {e}\"\n            ))\n        })?;\n    file.write_all(content.as_bytes()).map_err(|e| {\n        AgentDriverError::ConfigBuildFailed(anyhow::anyhow!(\n            \"Failed to write temp file '{prefix}': {e}\"\n        ))\n    })?;\n    Ok(file)\n}\n\n/// Upload a [`SerializedBlock`] as the JSON block snapshot for a third-party harness conversation.\npub(crate) async fn upload_block_snapshot(\n    client: &dyn HarnessSupportClient,\n    conversation_id: AIConversationId,\n    block: SerializedBlock,\n) -> Result<()> {\n    log::info!(\"Uploading block snapshot for CLI agent to conversation {conversation_id}\");","sourceCodeStart":557,"sourceCodeEnd":593,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/agent_sdk/driver/harness/mod.rs#L557-L593","documentation":"Wrapped as AgentDriverError::ConfigBuildFailed when tempfile::Builder::new().prefix(..).suffix(..).tempfile() fails to create the file. The underlying {e} is an io::Error — common causes are an unwritable/missing temp dir (TMPDIR/TMP/TEMP), ENOSPC (disk full), EMFILE (fd exhaustion), or EACCES on the temp directory.","triggerScenarios":"Calling write_temp_file (used by third-party harnesses to stage prompts/system prompts and dodge shell-quoting issues) when the OS temp directory is misconfigured or exhausted: TMPDIR pointing at a nonexistent path, /tmp mounted noexec/full, too many open files, or sandbox profiles denying temp writes.","commonSituations":"CI runners with tiny /tmp; containers with TMPDIR set to an unmounted volume path; long-lived processes leaking fds; macOS app sandboxes restricting temp writes; disk-full conditions during large agent runs.","solutions":["Check the {e} suffix: ENOSPC → free disk space; EACCES → fix TMPDIR permissions; EMFILE → raise ulimit -n / close leaked fds.","Point TMPDIR (and TEMP/TMP on Windows) at an existing, writable directory with free space and restart the agent.","For sandboxes, grant write access to the temp location the harness uses."],"exampleFix":"# before\nTMPDIR=/nonexistent-dir warp agent run …  # create fails\n\n# after\nmkdir -p /var/tmp/warp && export TMPDIR=/var/tmp/warp\nwarp agent run …","handlingStrategy":"fallback","validationCode":"let tmp = std::env::temp_dir();\nlet probe = tempfile::Builder::new().prefix(\"probe\").tempfile_in(&tmp);\nanyhow::ensure!(probe.is_ok(), \"temp dir {:?} is not writable\", tmp);","typeGuard":null,"tryCatchPattern":"match write_temp_file(prefix, content, suffix) {\n    Err(AgentDriverError::ConfigBuildFailed(err)) if err.to_string().contains(\"Failed to create temp file\") => {\n        std::env::set_var(\"TMPDIR\", \"/var/tmp/warp-fallback\");\n        write_temp_file(prefix, content, suffix) // retry against the fallback dir\n    }\n    rest => rest,\n}","preventionTips":["Verify TMPDIR exists and is writable before launching harness flows that stage prompts on disk.","Monitor disk space and fd usage (df, ulimit -n) on long-running agent hosts.","Read the {e} suffix to pick the fix: ENOSPC→free space, EACCES→permissions, EMFILE→fd limit."],"tags":["filesystem","temp-files","io","configuration","rust"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}