Hmbown/CodeWhale · warning
tempdir
Error message
tempdir
What it means
Test panic from `tempfile::tempdir().expect("tempdir")` in a_first_launch_records_the_version_without_claiming_an_update: the temp home directory for record_launch could not be created, so the first-launch bookkeeping test aborts during setup.
Solutions
- Validate TMPDIR/TMP env vars point to an existing writable directory and recreate if needed.
- Free disk space or inodes on the partition backing the temp directory.
- Rerun with an explicit writable temp root: TMPDIR=$(mktemp -d) cargo test -p codewhale-release a_first_launch_records.
Example fix
// before cargo test -p codewhale-release // after TMPDIR=$(mktemp -d) cargo test -p codewhale-release a_first_launch_records_the_version
Defensive patterns
Strategy: try-catch
Validate before calling
assert!(std::env::temp_dir().exists(), "temp root 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 home = tempfile::tempdir()
.unwrap_or_else(|e| panic!("temp home unavailable: {e} — check TMPDIR and disk space")); Prevention
- Ensure CI containers mount a writable /tmp or set TMPDIR explicitly.
- Watch for disk-full conditions that surface first as tempdir creation failures.
- Run version-bookkeeping tests on local filesystems, not network mounts.
When it happens
Trigger: Calling tempfile::tempdir() when the OS temp directory is unavailable: invalid TMPDIR, missing temp root, full disk/inodes, or a sandboxed CI environment denying temp directory creation.
Common situations: CI runners with restricted or full /tmp; TMPDIR pointing at a removed path; disk quota exhaustion on the build machine.
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/819e5a5c08eed478.
Report an issue: GitHub.
Appendix: source
Thrown at crates/release/src/launch.rs:238
assert!(version_change(Some("0.9.9"), "0.9.10").is_some());
assert_eq!(version_change(Some("0.9.10"), "0.9.9"), None);
}
#[test]
fn a_prerelease_sorts_below_the_release_it_precedes() {
assert!(version_change(Some("0.9.11-pre"), "0.9.11").is_some());
assert_eq!(version_change(Some("0.9.11"), "0.9.11-pre"), None);
}
#[test]
fn an_unparseable_version_on_either_side_produces_no_hint() {
assert_eq!(version_change(Some("not-a-version"), "0.9.11"), None);
assert_eq!(version_change(Some("0.9.10"), "also-not-a-version"), None);
}
#[test]
fn a_first_launch_records_the_version_without_claiming_an_update() {
let home = tempfile::tempdir().expect("tempdir");
let outcome = record_launch(home.path(), "0.9.10");
assert_eq!(outcome.change, None);
assert!(outcome.record_error.is_none());
assert_eq!(
LastLaunch::load(&record_path_in(home.path())).map(|r| r.version),
Some("0.9.10".to_string())
);
}
#[test]
fn the_hint_fires_once_and_not_again_on_the_next_launch() {
let home = tempfile::tempdir().expect("tempdir");
record_launch(home.path(), "0.9.10");
assert!(record_launch(home.path(), "0.9.11").change.is_some());
assert_eq!(record_launch(home.path(), "0.9.11").change, None);
}
// The record answers "what ran last", so a downgrade must overwrite it.View on GitHub (pinned to 433685b202)