Hmbown/CodeWhale · error

store into a fresh directory

Error message

store into a fresh directory

What it means

Test panic from `.store(&path).expect("store into a fresh directory")`: storing the update-check cache into a path whose parent directories (`nested/home`) do not exist yet failed. store is supposed to create_dir_all the parent before the temp-file write, so this failing means directory creation itself was refused or the subsequent write/rename failed.

Solutions

  1. Read the anyhow context ("failed to create …") to confirm whether create_dir_all or the write/rename step failed.
  2. Verify the base tempdir is writable and the sandbox permits mkdir -p of nested paths.
  3. Free disk space or fix permissions on the temp filesystem, then rerun the single test to confirm.

Example fix

// before
UpdateCheckCache::now(Some("v1.0.0".to_string()))
    .store(&path)
    .expect("store into a fresh directory");
// after — pre-check the environment the test depends on
assert!(dir.path().status().map(|m| m.permissions().readonly() == false).unwrap_or(false));
UpdateCheckCache::now(Some("v1.0.0".to_string()))
    .store(&path)
    .expect("store into a fresh directory");
Defensive patterns

Strategy: validation

Validate before calling

// mkdir -p the target parent up front so failures are attributable
let dir = path.parent().unwrap();
std::fs::create_dir_all(dir).expect("failed to create nested home directory");

Type guard

fn can_create_nested_under(base: &Path) -> bool {
    base.metadata().map(|m| !m.permissions().readonly()).unwrap_or(false)
}

Try / catch

store_result.unwrap_or_else(|e| panic!("store into fresh dir failed: {e:#}")); // context names the failing step

Prevention

When it happens

Trigger: Calling UpdateCheckCache::store on cache_path_in(&home.join("nested").join("home")): panics if create_dir_all hits permission denied (read-only tempdir, restricted sandbox), the disk is full, or the temp-file write/rename within the freshly created directory fails.

Common situations: Deeply nested paths exceeding filesystem limits in unusual TMPDIRs; sandboxed CI blocking mkdir; read-only or quota'd temp filesystems; concurrent tests racing on the same temp path.

Understand the failure class

Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/c865dbc0a2ab8ec3. Report an issue: GitHub.

Appendix: source

Thrown at crates/release/src/check.rs:244

        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());
    }

    #[test]
    fn store_creates_a_missing_home_directory() {
        let dir = tempfile::tempdir().expect("tempdir");
        let path = cache_path_in(&dir.path().join("nested").join("home"));
        UpdateCheckCache::now(Some("v1.0.0".to_string()))
            .store(&path)
            .expect("store into a fresh directory");
        assert!(path.exists());
    }

    #[test]
    fn a_corrupt_or_absent_cache_reads_as_none() {
        let dir = tempfile::tempdir().expect("tempdir");
        let path = cache_path_in(dir.path());
        assert_eq!(UpdateCheckCache::load(&path), None);
        std::fs::write(&path, b"{ not json").expect("write junk");
        assert_eq!(UpdateCheckCache::load(&path), None);
    }

    #[test]
    fn falsey_flag_values_do_not_count_as_set() {
        for value in ["", "0", "false", "FALSE", " no ", "off"] {
            assert!(
                !flag_value_is_truthy(value),
                "{value:?} should not read as set"

View on GitHub (pinned to 433685b202)