Hmbown/CodeWhale · error · anyhow::Error

is not a regular file

Error message

{} is not a regular file

What it means

read_stable_workspace_dotenv opens the workspace .env without following symlinks and inspects its metadata; if the opened path is not a regular file (e.g. a directory, device, FIFO, or socket), it bails. This guard ensures credentials are only read from a plain, workspace-owned file.

Solutions

  1. Check what `.env` is (`ls -la .env`, `stat .env`); if it is a directory, remove or rename it.
  2. Create a real regular file: `touch .env` and put literal values in it.
  3. Stop any process holding a FIFO/socket named .env in the workspace.
  4. If a mount or volume is substituting .env, fix the mount so a regular file is presented.

Example fix

// shell before
mkdir .env   # accidentally created a directory
// after
rm -rf .env && touch .env && echo 'API_KEY=...' > .env
Defensive patterns

Strategy: validation

Validate before calling

// shell
[ -f .env ] && [ ! -L .env ] || { echo '.env must be a regular file'; exit 1; }

Prevention

When it happens

Trigger: A path named `.env` in the workspace that is actually a directory, named pipe, device node, or other non-regular filesystem object when Codewhale loads workspace dotenv credentials.

Common situations: A .env directory created by mistake (e.g. `mkdir .env`), a FIFO left by a script, or a devcontainer mount that presents .env as something other than a regular file.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at crates/tui/src/lib.rs:2942

        }
        if ch == '#' && !double_quoted {
            comment = true;
            continue;
        }
        if ch == '$' {
            return true;
        }
    }
    false
}

fn read_stable_workspace_dotenv(path: &Path) -> Result<Vec<u8>> {
    let mut file = open_workspace_dotenv_without_following_links(path)?;
    let metadata = file
        .metadata()
        .map_err(|error| anyhow!("could not inspect {}: {error}", path.display()))?;
    if !metadata.is_file() {
        bail!("{} is not a regular file", path.display());
    }
    if workspace_dotenv_has_multiple_links(&file, &metadata)? {
        bail!(
            "{} has multiple filesystem links, not a unique workspace-owned file",
            path.display()
        );
    }
    if metadata.len() > MAX_WORKSPACE_DOTENV_BYTES {
        bail!(
            "{} exceeds the {} byte workspace .env limit",
            path.display(),
            MAX_WORKSPACE_DOTENV_BYTES
        );
    }

    let mut contents = Vec::with_capacity(metadata.len() as usize);
    (&mut file)
        .take(MAX_WORKSPACE_DOTENV_BYTES + 1)

View on GitHub (pinned to 73e0f67d83)