astrid-runtime/astrid · error

auto-created mountpoint is not empty: {}

Error message

auto-created mountpoint is not empty: {}

What it means

When tearing down a mountpoint that this provider auto-created, cleanup_created_mountpoint() refuses to remove the directory if it is no longer empty after unmount — something wrote files into it (or a failed mount left debris), and deleting a non-empty directory could destroy user data.

Source

Thrown at crates/astrid-storage-provider-fskit/src/main.rs:418

        errors.push(format!("registry: {error:#}"));
    }
    if errors.is_empty()
        && let Err(error) = cleanup_created_mountpoint(mountpoint, auto_created)
    {
        errors.push(format!("cleanup: {error:#}"));
    }
    rollback_outcome(true, &errors)
}

fn cleanup_created_mountpoint(mountpoint: &Path, auto_created: bool) -> Result<()> {
    if !auto_created {
        return Ok(());
    }
    validate_unmounted_mountpoint(mountpoint)?;
    let mut entries = std::fs::read_dir(mountpoint)
        .with_context(|| format!("read auto-created mountpoint {}", mountpoint.display()))?;
    if entries.next().is_some() {
        bail!(
            "auto-created mountpoint is not empty: {}",
            mountpoint.display()
        );
    }
    std::fs::remove_dir(mountpoint)
        .with_context(|| format!("remove auto-created mountpoint {}", mountpoint.display()))
}

fn prepare_mountpoint(
    requested: Option<PathBuf>,
    view: &astrid_core::storage_provider::StorageProviderViewV1,
) -> Result<(PathBuf, bool)> {
    let mountpoint =
        requested.map_or_else(|| default_mountpoint(std::env::var_os("HOME"), view), Ok)?;
    validate_mountpoint_layout(&mountpoint)?;
    let existed = match std::fs::symlink_metadata(&mountpoint) {
        Ok(_) => true,
        Err(error) if error.kind() == std::io::ErrorKind::NotFound => false,

View on GitHub (pinned to affd8760f4)

Solutions

  1. Inspect the directory and move out any files you need, then re-run the unmount/cleanup.
  2. Verify the fs was actually unmounted — if a hidden native mount still holds files, unmount it first.
  3. Remove the directory manually only after confirming its contents are not needed.
  4. Avoid pointing mounts at directories other processes write to; use a dedicated default mountpoint.
Defensive patterns

Strategy: validation

Validate before calling

fn mountpoint_is_empty(path: &Path) -> std::io::Result<bool> {
    Ok(std::fs::read_dir(path)?.next().is_none())
}
// call before unmount/cleanup; if false, surface files to the user instead of removing

Try / catch

if let Err(e) = cleanup_created_mountpoint(&mountpoint, auto_created) {
    if e.to_string().contains("auto-created mountpoint is not empty") {
        // leave directory intact; notify user to inspect and remove manually
    }
}

Prevention

When it happens

Trigger: After unmount or rollback, validate_unmounted_mountpoint passed but read_dir still finds entries (entries.next().is_some()); triggered from mount, unmount, and rollback_after_native_failure for auto-created mountpoints only.

Common situations: User or another process placed files in ~/Astrid/<principal> while the fs was mounted or right after unmount; a crashed fskit daemon left journal files inside the mountpoint; race between two concurrent unmounts.

Related errors


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/09e04c6d3c825ea3. Report an issue: GitHub.