Hmbown/CodeWhale · error

not one regular file

Error message

not one regular file

What it means

On Unix, `runtime_store_file_identity` computes a (dev, ino) identity for a Runtime store file so two handles can be compared as the same underlying file. The ensure! rejects any file whose metadata is not a regular file or whose hard-link count is not exactly 1, because identity tracking only makes sense for a single unshared regular file. If a symlink target, directory, FIFO, device, or a hard-linked file is passed in, this error fires.

Solutions

  1. Check the store path resolves to a real regular file: `file <path>` and `stat -c '%h %F' <path>`; remove symlinks/hard links causing nlink > 1
  2. Recreate the store as a plain regular file (copy its content to a new single-link file and update configuration)
  3. Verify the code opening the store uses File::open on the regular file itself, not a directory or special file

Example fix

// before (fails: nlink > 1 from hard link)
let f = File::open("/store/runtime.bin")?;
let id = runtime_store_file_identity(&f)?;
// after (guaranteed single-link regular file)
std::fs::copy("/store/runtime.bin", "/store/runtime-unique.bin")?;
let f = File::open("/store/runtime-unique.bin")?;
assert_eq!(f.metadata()?.nlink(), 1);
let id = runtime_store_file_identity(&f)?;
Defensive patterns

Strategy: validation

Validate before calling

let m = f.metadata()?;
if !(m.is_file() && m.nlink() == 1) {
    return Err(anyhow!("store must be a single-link regular file"));
}

Type guard

fn is_storable_file(f: &File) -> bool {
    f.metadata().map(|m| m.is_file() && m.nlink() == 1).unwrap_or(false)
}

Try / catch

match runtime_store_file_identity(&f) {
    Ok((dev, ino)) => use_identity(dev, ino),
    Err(e) => log::error!("store file unusable: {e:#}"),
}

Prevention

When it happens

Trigger: Calling code passes a `File` handle whose underlying path is a directory, FIFO, socket, device node, or symlink-resolved special file (metadata.is_file() == false), or a file that has been hard-linked into a second location (metadata.nlink() > 1).

Common situations: Pointing the runtime store at a symlinked or bind-mounted path that resolves to something with nlink > 1; a tool created hard links between store snapshots; the store path was misconfigured to a directory or device.

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/1e76197d9a14abff. Report an issue: GitHub.

Appendix: source

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

                    error.kind(),
                    std::io::ErrorKind::WouldBlock | std::io::ErrorKind::Interrupted
                ) =>
            {
                wait_for_event_lock(started, EVENT_TRANSACTION_LOCK_TIMEOUT)?;
            }
            Err(error) => {
                return Err(error).context("Failed to lock Runtime store ownership");
            }
        }
    }
}

#[cfg(unix)]
fn runtime_store_file_identity(file: &File) -> Result<(u64, u64)> {
    use std::os::unix::fs::MetadataExt as _;

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

View on GitHub (pinned to 73e0f67d83)