Hmbown/CodeWhale · error

home

Error message

home

What it means

This `expect` panics when `tempfile::tempdir()` fails to create a temporary directory, aborting the test with 'home' at crates/tui/src/client.rs:7862. The test needs a scratch directory to point `CODEWHALE_HOME` at; tempfile returns `Err` when the OS cannot create it.

Solutions

  1. Inspect the underlying `io::Error` (`tempfile::tempdir().unwrap_err()`) to see the OS reason
  2. Check `TMPDIR`/`TEMP` env vars for invalid or read-only values inside the test process
  3. Free disk space or clean stale temp directories
  4. Fall back to an explicit writable directory via `tempfile::Builder::new().tempdir_in(...)`

Example fix

// before
let home = tempfile::tempdir().expect("home");
// after
let home = tempfile::tempdir()
    .unwrap_or_else(|e| panic!("home: failed to create temp dir: {e}"));
Defensive patterns

Strategy: try-catch

Validate before calling

// check env before creating
debug_assert!(std::env::var("TMPDIR").map(|p| std::path::Path::new(&p).is_dir()).unwrap_or(true),
    "TMPDIR is not a directory");

Try / catch

let home = tempfile::tempdir()
    .unwrap_or_else(|e| panic!("temp dir creation failed: {e}"));

Prevention

When it happens

Trigger: Calling `tempfile::tempdir().expect("home")` when `TMPDIR` points somewhere unwritable, the filesystem is full, sandboxed CI denies mkdtemp, or a `TMPDIR` override in the test environment is invalid.

Common situations: CI containers with read-only /tmp; `lock_test_env` or another guard set `TMPDIR` to a nonexistent path; disk quota exhaustion on long test runs leaving stale temp dirs.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/e9283b9d835c7e21. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/client.rs:7862

        assert_eq!(requests.len(), 1);
        assert_codewhale_bearer(&requests[0]);
        assert_eq!(
            requests[0]
                .headers
                .get("anthropic-version")
                .and_then(|value| value.to_str().ok()),
            Some("2023-06-01")
        );
    }

    /// A catalog row stating `codewhale.protocol = "responses"` must dispatch
    /// to the account API's Responses surface — `{base}/responses` — not the
    /// Chat Completions default its `openai/` namespace alone would imply.
    #[tokio::test]
    async fn codewhale_responses_catalog_row_dispatches_to_responses_endpoint() {
        let _env = crate::test_support::lock_test_env();
        let _live = crate::provider_lake::lock_live_snapshot();
        let home = tempfile::tempdir().expect("home");
        let _home = crate::test_support::EnvVarGuard::set("CODEWHALE_HOME", home.path());
        crate::provider_catalog_live::reset_cache_for_test();
        crate::provider_lake::clear_live_snapshot();

        let server = MockServer::start().await;
        Mock::given(method("POST"))
            .and(path("/v1/responses"))
            .respond_with(
                ResponseTemplate::new(200)
                    .insert_header("Content-Type", "text/event-stream")
                    .set_body_string(concat!(
                        "data: {\"type\":\"response.completed\",\"response\":{\"status\":\"completed\"",
                        ",\"usage\":{\"input_tokens\":3,\"output_tokens\":1}}}\n\n",
                        "data: [DONE]\n\n"
                    )),
            )
            .expect(1)
            .mount(&server)

View on GitHub (pinned to 73e0f67d83)