{"record":{"id":"c56e5c6ba7fbbc78","repo":"Hmbown/CodeWhale","slug":"could-not-read-error","errorCode":null,"errorMessage":"could not read {}: {error}","messagePattern":"could not read (.+?): (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/lib.rs","lineNumber":2610,"sourceCode":"    if workspace_dotenv_has_multiple_links(&file, &metadata)? {\n        bail!(\n            \"{} has multiple filesystem links, not a unique workspace-owned file\",\n            path.display()\n        );\n    }\n    if metadata.len() > MAX_WORKSPACE_DOTENV_BYTES {\n        bail!(\n            \"{} exceeds the {} byte workspace .env limit\",\n            path.display(),\n            MAX_WORKSPACE_DOTENV_BYTES\n        );\n    }\n\n    let mut contents = Vec::with_capacity(metadata.len() as usize);\n    (&mut file)\n        .take(MAX_WORKSPACE_DOTENV_BYTES + 1)\n        .read_to_end(&mut contents)\n        .map_err(|error| anyhow!(\"could not read {}: {error}\", path.display()))?;\n    if contents.len() as u64 > MAX_WORKSPACE_DOTENV_BYTES {\n        bail!(\n            \"{} exceeds the {} byte workspace .env limit\",\n            path.display(),\n            MAX_WORKSPACE_DOTENV_BYTES\n        );\n    }\n    Ok(contents)\n}\n\n#[cfg(unix)]\nfn workspace_dotenv_has_multiple_links(\n    _file: &std::fs::File,\n    metadata: &std::fs::Metadata,\n) -> Result<bool> {\n    use std::os::unix::fs::MetadataExt;\n\n    Ok(metadata.nlink() > 1)","sourceCodeStart":2592,"sourceCodeEnd":2628,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/crates/tui/src/lib.rs#L2592-L2628","documentation":"After the size and link-count gates pass, Codewhale streams up to MAX_WORKSPACE_DOTENV_BYTES + 1 bytes from the open .env handle. A read error mid-stream fails with 'could not read {path}'; partial contents are never used.","triggerScenarios":"read(2) on the open handle returns an error: EIO from failing storage, the file truncated or removed mid-read, a FUSE/network volume dropping out, or a locked sparse file on some platforms.","commonSituations":"Disk or mount errors; another process truncating .env during startup; cloud-sync clients (Dropbox/OneDrive) swapping the file under the open handle.","solutions":["Confirm the file is stable: checksum it twice a moment apart, then retry","Pause or exclude .env from cloud-sync agents and retry","If EIO repeats, check storage health (dmesg, smartctl) and repair the volume","Copy .env to a fresh file in the same directory and atomically replace it"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"let first = std::fs::read(\".env\")?;\nstd::thread::sleep(std::time::Duration::from_millis(50));\nlet second = std::fs::read(\".env\")?;\nif first != second {\n    eprintln!(\".env is changing while being read; stabilize it before launching\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Exclude .env from cloud-sync folders or pause sync during startup","Write .env atomically (temp file + rename) instead of truncating in place","Retry once after fixing storage issues; a mid-read EIO is often transient"],"tags":["rust","env","filesystem","io-error"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}