warpdotdev/warp · error · AgentDriverError::ConfigBuildFailed

Failed to create temp file '{prefix}': {e}

Error message

Failed to create temp file '{prefix}': {e}

What it means

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.

Source

Thrown at app/src/ai/agent_sdk/driver/harness/mod.rs:575

        .ok()
        .flatten()
}

/// Create a [`NamedTempFile`] with the given prefix and write `content` into it.
///
/// Used by third-party harnesses to stage prompts / system prompts on disk
/// before launching the CLI, avoiding shell-quoting issues with complex input.
pub(super) fn write_temp_file(
    prefix: &str,
    content: &str,
    suffix: &str,
) -> Result<NamedTempFile, AgentDriverError> {
    let mut file = tempfile::Builder::new()
        .prefix(prefix)
        .suffix(suffix)
        .tempfile()
        .map_err(|e| {
            AgentDriverError::ConfigBuildFailed(anyhow::anyhow!(
                "Failed to create temp file '{prefix}': {e}"
            ))
        })?;
    file.write_all(content.as_bytes()).map_err(|e| {
        AgentDriverError::ConfigBuildFailed(anyhow::anyhow!(
            "Failed to write temp file '{prefix}': {e}"
        ))
    })?;
    Ok(file)
}

/// Upload a [`SerializedBlock`] as the JSON block snapshot for a third-party harness conversation.
pub(crate) async fn upload_block_snapshot(
    client: &dyn HarnessSupportClient,
    conversation_id: AIConversationId,
    block: SerializedBlock,
) -> Result<()> {
    log::info!("Uploading block snapshot for CLI agent to conversation {conversation_id}");

View on GitHub (pinned to e72fd7aacb)

Solutions

  1. Check the {e} suffix: ENOSPC → free disk space; EACCES → fix TMPDIR permissions; EMFILE → raise ulimit -n / close leaked fds.
  2. Point TMPDIR (and TEMP/TMP on Windows) at an existing, writable directory with free space and restart the agent.
  3. For sandboxes, grant write access to the temp location the harness uses.

Example fix

# before
TMPDIR=/nonexistent-dir warp agent run …  # create fails

# after
mkdir -p /var/tmp/warp && export TMPDIR=/var/tmp/warp
warp agent run …
Defensive patterns

Strategy: fallback

Validate before calling

let tmp = std::env::temp_dir();
let probe = tempfile::Builder::new().prefix("probe").tempfile_in(&tmp);
anyhow::ensure!(probe.is_ok(), "temp dir {:?} is not writable", tmp);

Try / catch

match write_temp_file(prefix, content, suffix) {
    Err(AgentDriverError::ConfigBuildFailed(err)) if err.to_string().contains("Failed to create temp file") => {
        std::env::set_var("TMPDIR", "/var/tmp/warp-fallback");
        write_temp_file(prefix, content, suffix) // retry against the fallback dir
    }
    rest => rest,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of warpdotdev/warp@e72fd7aacb (2026-08-16). Data as JSON: /api/errors/17c7ff55a51a1f29. Report an issue: GitHub.