Hmbown/CodeWhale · warning
tempdir
Error message
tempdir
What it means
Test panic from `tempfile::tempdir().expect("tempdir")` in the release crate's update-check tests: the tempdir helper failed to create a temporary directory. This is environmental, not logic — the test cannot even set up its scratch home directory.
Solutions
- Verify the system temp directory exists and is writable: check TMPDIR/TMP env vars and `ls -ld $TMPDIR /tmp`.
- Free disk space or inodes on the partition backing the temp directory.
- Set TMPDIR to a writable path (e.g. TMPDIR=$(mktemp -d) cargo test -p codewhale-release) and rerun the test.
Example fix
// before cargo test -p codewhale-release // after — point the test harness at a guaranteed-writable temp dir TMPDIR=$(mktemp -d) cargo test -p codewhale-release store_then_load_round_trips
Defensive patterns
Strategy: try-catch
Validate before calling
// check the temp root is usable before running the suite
std::env::temp_dir()
.exists()
.then_some(())
.expect("system temp directory must exist; check TMPDIR"); Type guard
fn tempdir_usable() -> bool {
let probe = std::env::temp_dir().join(".cw-probe");
std::fs::write(&probe, b"x").is_ok() && std::fs::remove_file(&probe).is_ok()
} Try / catch
let dir = tempfile::tempdir()
.unwrap_or_else(|e| panic!("tempdir unavailable — check TMPDIR/disk space: {e}")); Prevention
- Keep TMPDIR pointing at an existing writable directory in CI configuration.
- Monitor disk/inode headroom on build agents.
- Run filesystem-touching tests on local tmpfs rather than network mounts.
When it happens
Trigger: Calling tempfile::tempdir() in store_then_load_round_trips_and_survives_an_existing_file: panics when the OS temp directory is missing/unwritable (TMPDIR pointing at a removed path), the disk is full, or sandboxed CI restricts temp directory creation.
Common situations: CI runners with read-only or full /tmp; TMPDIR set to a nonexistent path; container sandboxes without /tmp; exhausted inodes or disk space on build machines.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/863bbce8f93dd96a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/release/src/check.rs:217
let entry = UpdateCheckCache {
checked_at_unix: 1_000_000,
latest_tag: None,
};
assert!(!entry.is_fresh(1_000_000, 0));
}
#[test]
fn a_future_timestamp_is_stale_not_permanently_fresh() {
let entry = UpdateCheckCache {
checked_at_unix: 2_000_000,
latest_tag: Some("v9.9.9".to_string()),
};
assert!(!entry.is_fresh(1_000_000, 24));
}
#[test]
fn store_then_load_round_trips_and_survives_an_existing_file() {
let dir = tempfile::tempdir().expect("tempdir");
let path = cache_path_in(dir.path());
assert_eq!(path.file_name().unwrap(), UPDATE_CHECK_CACHE_FILE);
let first = UpdateCheckCache {
checked_at_unix: 42,
latest_tag: Some("v0.9.5".to_string()),
};
first.store(&path).expect("store");
assert_eq!(UpdateCheckCache::load(&path), Some(first));
// Overwriting in place must not leave the temp file behind.
let second = UpdateCheckCache {
checked_at_unix: 99,
latest_tag: None,
};
second.store(&path).expect("overwrite");
assert_eq!(UpdateCheckCache::load(&path), Some(second));
assert!(!path.with_extension("json.tmp").exists());View on GitHub (pinned to 433685b202)