{"record":{"id":"d0c4102222c2e28d","repo":"Hmbown/CodeWhale","slug":"could-not-inspect-workspace-env-link-count-erro","errorCode":null,"errorMessage":"could not inspect workspace .env link count: {error}","messagePattern":"could not inspect workspace \\.env link count: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/lib.rs","lineNumber":2648,"sourceCode":"\n#[cfg(windows)]\nfn workspace_dotenv_has_multiple_links(\n    file: &std::fs::File,\n    _metadata: &std::fs::Metadata,\n) -> Result<bool> {\n    use std::os::windows::io::AsRawHandle;\n    use windows::Win32::Foundation::HANDLE;\n    use windows::Win32::Storage::FileSystem::{\n        BY_HANDLE_FILE_INFORMATION, GetFileInformationByHandle,\n    };\n\n    let mut information = BY_HANDLE_FILE_INFORMATION::default();\n    // SAFETY: `file` owns a live kernel handle for the already-open `.env`;\n    // `information` remains writable for the duration of this synchronous\n    // call. No path lookup or re-open occurs here.\n    unsafe {\n        GetFileInformationByHandle(HANDLE(file.as_raw_handle()), &mut information)\n            .map_err(|error| anyhow!(\"could not inspect workspace .env link count: {error}\"))?;\n    }\n    Ok(information.nNumberOfLinks > 1)\n}\n\n#[cfg(not(any(unix, windows)))]\nfn workspace_dotenv_has_multiple_links(\n    _file: &std::fs::File,\n    _metadata: &std::fs::Metadata,\n) -> Result<bool> {\n    Ok(false)\n}\n\n#[cfg(unix)]\nfn open_workspace_dotenv_without_following_links(path: &Path) -> Result<std::fs::File> {\n    use std::os::unix::fs::OpenOptionsExt;\n\n    std::fs::OpenOptions::new()\n        .read(true)","sourceCodeStart":2630,"sourceCodeEnd":2666,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/crates/tui/src/lib.rs#L2630-L2666","documentation":"On Windows, Codewhale detects hard-linked .env files by calling GetFileInformationByHandle on the already-open handle and reading nNumberOfLinks. If the Win32 call fails, the load stops with 'could not inspect workspace .env link count' — the security check is never skipped silently.","triggerScenarios":"GetFileInformationByHandle fails: the handle was invalidated, the volume does not support the metadata query, a network redirector returned an error (SMB share dropping, DFS issues), or a filter driver blocked the query.","commonSituations":"A .env on a network share or in a OneDrive placeholder state; the file locked or converted by another process between open and query; antivirus or DLP filter drivers interfering with handle queries.","solutions":["Move the workspace .env onto a local NTFS volume and retry","Pause sync/antivirus agents that virtualize the workspace folder and retry","Reconnect the network share, then retry","Verify the file is a plain local file: fsutil hardlink list .env"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# PowerShell pre-flight: the file must be a local plain file\nfsutil hardlink list .env   # must report exactly one link\n(Get-Item .env).LinkType    # must be empty (not a symlink/junction)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the workspace .env on local NTFS, not a network share or sync placeholder","Exclude the workspace from sync and AV filters that virtualize files","Ensure no other process holds .env open at startup"],"tags":["rust","windows","env","filesystem","win32"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}