Hmbown/CodeWhale · error · anyhow::Error
has multiple filesystem links, not a unique workspace-owned…
Error message
{} has multiple filesystem links, not a unique workspace-owned file What it means
After confirming the workspace .env is a regular file, read_stable_workspace_dotenv checks the hard-link count via workspace_dotenv_has_multiple_links; more than one link means the inode is shared, so the file is not uniquely owned by the workspace. Sharing an inode lets another path (possibly outside the workspace) alter the credential file after validation, so loading is refused.
Solutions
- Replace the hard link with a copy: `rm .env && cp /path/to/source .env` (cp makes a fresh inode).
- Find other links with `find / -samefile .env` and remove or unlink them.
- Re-checkout or re-sync the file if your tooling (overlay fs, dotfile manager) hard-links unchanged files.
- Store the .env only inside the workspace and reference it, rather than linking it in.
Example fix
// before ln ~/.secrets/codewhale.env .env // after cp ~/.secrets/codewhale.env .env # copy, not hard link
Defensive patterns
Strategy: validation
Validate before calling
// shell
links=$(stat -c %h .env 2>/dev/null || stat -f %l .env); [ "$links" = "1" ] || { echo '.env has multiple hard links'; exit 1; } Prevention
- Always copy (.env files in, never hard-link them.
- Audit link counts with `find . -samefile .env` when dotfile/backup tools are in play.
- Keep the credential file owned solely by the workspace.
When it happens
Trigger: Workspace `.env` has st_nlink > 1: created via `ln .env other-name`, hard-linked from a dotfiles repo, or checked out from a filesystem (e.g. some git worktree/overlay setups) that hard-links unchanged files.
Common situations: Hard-linking .env into a secrets repo, backup tools that hard-link, or overlay/copy-on-write checkouts that preserve link counts.
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
- Codewhale-owned credential file must be singly linked
- could not inspect workspace .env link count
- could not securely open
- is a symbolic link, not a workspace-owned file
- private sidecar file
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/b32fe90608a2164e.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/lib.rs:2945
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)
.read_to_end(&mut contents)
.map_err(|error| anyhow!("could not read {}: {error}", path.display()))?;
if contents.len() as u64 > MAX_WORKSPACE_DOTENV_BYTES {View on GitHub (pinned to 73e0f67d83)