Hmbown/CodeWhale · error

not a regular non-reparse file

Error message

not a regular non-reparse file

What it means

On Windows, `runtime_store_file_identity` reads a file's metadata and rejects anything that is not a regular file or that carries the FILE_ATTRIBUTE_REPARSE_POINT attribute (symlinks, junctions, mount points). Identity tracking requires a plain physical file, and reparse points can redirect to arbitrary targets, so the function refuses them. The ensure! fires before the Win32 GetFileInformationByHandle call when either condition holds.

Solutions

  1. Resolve the path to its real target before opening (`std::fs::canonicalize`) and ensure it is a regular file without reparse attributes
  2. Move the runtime store out of synced/junctioned directories (OneDrive, Documents redirected) into a plain local path
  3. Verify the configured store path is not a directory or junction

Example fix

// before
let f = File::open(&cfg.runtime_store_path)?; // path is a junction
let id = runtime_store_file_identity(&f)?;
// after
let real = std::fs::canonicalize(&cfg.runtime_store_path)?;
let meta = std::fs::metadata(&real)?;
anyhow::ensure!(meta.is_file(), "store must be a regular file");
let f = File::open(&real)?;
let id = runtime_store_file_identity(&f)?;
Defensive patterns

Strategy: validation

Validate before calling

let meta = std::fs::metadata(path)?;
if !meta.is_file() {
    return Err(anyhow!("{} is not a regular file", path.display()));
}

Type guard

fn is_plain_windows_file(f: &File) -> bool {
    f.metadata().map(|m| m.is_file() && m.file_attributes() & 0x400 == 0).unwrap_or(false)
} // 0x400 == FILE_ATTRIBUTE_REPARSE_POINT

Try / catch

match runtime_store_file_identity(&f) {
    Ok(id) => id,
    Err(e) => { eprintln!("store path must be a plain local file: {e:#}"); std::process::exit(1); }
}

Prevention

When it happens

Trigger: Passing a `File` handle to a path that is a directory, or to a symlink/junction/reparse point (OneDrive placeholder, Dev Drive mount, WSL symlink), or a file with metadata.file_attributes() & FILE_ATTRIBUTE_REPARSE_POINT != 0.

Common situations: Runtime store configured under a OneDrive-synced or junctioned directory on Windows; path given via a symbolic link; the configured path is actually a directory.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/f5f5538378de83c8. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/runtime_threads.rs:13856

    let metadata = file.metadata()?;
    anyhow::ensure!(
        metadata.is_file() && metadata.nlink() == 1,
        "not one regular file"
    );
    Ok((metadata.dev(), metadata.ino()))
}

#[cfg(windows)]
fn runtime_store_file_identity(file: &File) -> Result<(u64, u64)> {
    use std::os::windows::fs::MetadataExt as _;
    use std::os::windows::io::AsRawHandle as _;
    use windows_sys::Win32::Storage::FileSystem::{
        BY_HANDLE_FILE_INFORMATION, FILE_ATTRIBUTE_REPARSE_POINT, GetFileInformationByHandle,
    };

    let metadata = file.metadata()?;
    let safe = metadata.is_file() && metadata.file_attributes() & FILE_ATTRIBUTE_REPARSE_POINT == 0;
    anyhow::ensure!(safe, "not a regular non-reparse file");
    let mut info = BY_HANDLE_FILE_INFORMATION::default();
    // SAFETY: the handle and writable output remain valid for the call.
    if unsafe { GetFileInformationByHandle(file.as_raw_handle(), &mut info) } == 0 {
        return Err(std::io::Error::last_os_error()).context("Inspect Runtime store file identity");
    }
    anyhow::ensure!(info.nNumberOfLinks == 1, "has multiple filesystem links");
    Ok((
        u64::from(info.dwVolumeSerialNumber),
        (u64::from(info.nFileIndexHigh) << 32) | u64::from(info.nFileIndexLow),
    ))
}

#[cfg(all(not(unix), not(windows)))]
fn runtime_store_file_identity(file: &File) -> Result<(u64, u64)> {
    anyhow::ensure!(file.metadata()?.is_file(), "must be a regular file");
    Ok((0, 0))
}

View on GitHub (pinned to 73e0f67d83)