astrid-runtime/astrid · error
temporary home
Error message
temporary home
What it means
Test setup assertion in `audit_retirement_validates_tree_and_removes_only_verified_source`: `tempfile::tempdir()` must yield a scratch home directory for constructing an `AstridHome`. The `expect("temporary home")` fires when the OS cannot create the temporary directory (permissions or path issues), so the retirement test cannot run.
Source
Thrown at crates/astrid-kernel/src/audit_retirement_tests.rs:8
use super::{preflight_legacy_audit_sources, require_audit_integrity, retire_legacy_audit_dir};
use astrid_audit::ChainVerificationResult;
use astrid_core::SessionId;
use astrid_core::dirs::AstridHome;
#[test]
fn audit_retirement_validates_tree_and_removes_only_verified_source() {
let directory = tempfile::tempdir().expect("temporary home");
let home = AstridHome::from_path(directory.path().join(".astrid"));
home.ensure().expect("home layout");
let principal_home = home.principal_home(&astrid_core::PrincipalId::default());
principal_home.ensure().expect("legacy principal layout");
std::fs::write(principal_home.audit_dir().join("entry"), b"audit").expect("audit fixture");
retire_legacy_audit_dir(&home, &principal_home.audit_dir()).expect("retire audit source");
assert!(!principal_home.audit_dir().exists());
assert!(
!home
.migrations_dir()
.join("audit-principal-home.retired")
.exists()
);
}
#[cfg(unix)]
#[test]View on GitHub (pinned to affd8760f4)
Solutions
- Free space / fix permissions on the temp filesystem used by the test runner.
- Set `TMPDIR` to a writable location before running the tests.
- If sandbox rules block tempfile, allow writes to the system temp dir in the sandbox config.
- Retry the test once if the failure was transient (e.g. concurrent cleanup).
Example fix
// before
let directory = tempfile::tempdir().expect("temporary home");
// after
let directory = tempfile::tempdir()
.unwrap_or_else(|e| panic!("tempdir creation failed (check TMPDIR/permissions): {e}")); Defensive patterns
Strategy: try-catch
Validate before calling
// Rust (test/CI): verify temp dir writability before running
let probe = std::env::temp_dir().join(".write_probe");
std::fs::write(&probe, b"x").expect("TMPDIR not writable");
let _ = std::fs::remove_file(&probe); Try / catch
// Rust: report environment context on tempdir failure
let directory = tempfile::tempdir()
.unwrap_or_else(|e| panic!("tempdir failed (TMPDIR={:?}): {e}", std::env::var("TMPDIR").ok())); Prevention
- Keep CI temp filesystems writable with adequate free space.
- Set an explicit TMPDIR in test runners and sandboxes.
- Clean up stale temp dirs periodically to avoid inode/space exhaustion.
- Avoid running test suites under read-only root filesystems without a writable tmp mount.
When it happens
Trigger: Calling `tempfile::tempdir()` when creating a directory under `$TMPDIR` fails — read-only /tmp, full filesystem, restricted permissions, or TMPDIR pointing at a non-writable path.
Common situations: CI runners with read-only or quota-exhausted temp dirs, sandboxed test environments blocking tmp creation, or a bad `TMPDIR` env var in the developer's shell.
Understand the failure class
Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.
Related errors
- home layout
- directory symlink {} not allowed in capsule source tree (ref
- mountpoint is already registered: {}
- capsule path escaped source root
- capsule path is not valid UTF-8
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/9d1a303b9593c596.
Report an issue: GitHub.