Hmbown/CodeWhale · warning
tempdir
Error message
tempdir
What it means
A `tempfile::tempdir().expect("tempdir")` panic in a `#[tokio::test]` in `crates/tui/src/tools/subagent/tests.rs`. The test creates a temporary directory to back a `SubAgentManager` store and asserts creation succeeds; failure aborts the test before any assertions run. The same expect pattern also appears in `crates/app-server/src/chat_completions.rs` test helpers, so the failure family is 'the test harness could not obtain a temp dir'.
Solutions
- Check `echo $TMPDIR` and confirm the directory exists and is writable; fix or unset it to fall back to /tmp.
- Free disk space or raise quota if the filesystem holding temp is full.
- Run the test outside the sandbox/with write permission for the temp location (e.g. grant the CI job tmpfs write access).
- For a more actionable failure, replace expect with a panic message including the underlying io::Error.
Example fix
// before
let tmp = tempdir().expect("tempdir");
// after
let tmp = tempdir().unwrap_or_else(|e| panic!("tempdir creation failed: {e}; TMPDIR={:?}", std::env::var("TMPDIR"))); Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight in CI setup:
let probe = tempfile::tempdir().expect("temp filesystem must be writable for tests");
Try / catch
let tmp = tempdir().unwrap_or_else(|e| panic!("tempdir failed: {e}; check TMPDIR and disk space")); Prevention
- Verify TMPDIR in CI images and keep /tmp writable.
- Monitor disk space on test runners.
- Surface io::Error details in test panics instead of bare expects.
When it happens
Trigger: `tempfile::tempdir()` returns Err when it cannot create a directory under the system temp root (TMPDIR): read-only /tmp, full disk, missing TMPDIR target, sandboxed CI denying tmpfs writes, or a very long path exceeding filename limits.
Common situations: Running tests in a restricted CI container or hermetic sandbox with no writable temp; TMPDIR pointing at a deleted or read-only path; disk quota exhausted during large test runs.
Understand the failure class
Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.
Related errors
- credential fixture
- event recovery chunk length fits u64
- event recovery chunk length fits usize
- first coordination interrupt
- first Stop
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/cc09cbf56ba152e0.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/tools/subagent/tests.rs:6545
.await
.get_worker_record("agent_cancel_probe")
.expect("worker record remains inspectable");
assert_eq!(
record
.events
.iter()
.filter(|event| event.status == AgentWorkerStatus::Cancelled)
.count(),
1,
"repeated stop must not append a second terminal outcome"
);
}
#[tokio::test]
async fn model_wait_cancel_fans_in_once_and_preserves_checkpoint() {
use tokio_util::sync::CancellationToken;
let tmp = tempdir().expect("tempdir");
let mut manager = SubAgentManager::new(tmp.path().to_path_buf(), 2);
let agent_id = "agent_model_wait_cancel".to_string();
let (input_tx, _input_rx) = mpsc::unbounded_channel();
let mut agent = SubAgent::new(
agent_id.clone(),
FleetRole::Worker,
"cancel while waiting on provider".to_string(),
make_assignment(),
"deepseek-v4-flash".to_string(),
None,
None,
input_tx,
tmp.path().to_path_buf(),
manager.current_session_boot_id.clone(),
);
agent.checkpoint = Some(make_checkpoint(
&agent_id,
1,View on GitHub (pinned to 73e0f67d83)