{"record":{"id":"0e89df37baed8706","repo":"facebook/flow","slug":"realpath-failed-for-existent-path","errorCode":null,"errorMessage":"Realpath failed for existent path {}","messagePattern":"Realpath failed for existent path (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust_port/crates/flow_common/src/files.rs","lineNumber":1432,"sourceCode":"        rev_suffix.insert(0, basename);\n        let prefix = Path::new(path)\n            .parent()\n            .map(|p| p.to_string_lossy().into_owned())\n            .unwrap_or_else(|| \".\".to_string());\n        // Sys.file_exists should always return true for / and for . so we should never get into\n        // infinite recursion. Let's assert that\n        assert!(prefix != path);\n        if Path::new(&prefix).exists() {\n            prefix\n        } else {\n            find_real_prefix(&prefix, rev_suffix)\n        }\n    }\n\n    let mut rev_suffix = Vec::new();\n    let real_prefix = find_real_prefix(path, &mut rev_suffix);\n    let abs = cached_canonicalize(Path::new(&real_prefix))\n        .unwrap_or_else(|_| panic!(\"Realpath failed for existent path {}\", real_prefix));\n    let abs_str = abs.to_string_lossy().into_owned();\n    rev_suffix.iter().fold(abs_str, |acc, part| {\n        Path::new(&acc).join(part).to_string_lossy().into_owned()\n    })\n}\n\npub fn module_file_exts(options: &FileOptions) -> Vec<&str> {\n    options\n        .module_file_exts\n        .iter()\n        .map(|s| s.as_str())\n        .collect()\n}\n\npub fn node_resolver_dirnames(options: &FileOptions) -> &[String] {\n    &options.node_resolver_dirnames\n}\n","sourceCodeStart":1414,"sourceCodeEnd":1450,"githubUrl":"https://github.com/facebook/flow/blob/5c865861998a8ccb7dbc82b0c1f511e9ef60c3d9/rust_port/crates/flow_common/src/files.rs#L1414-L1450","documentation":"Flow resolves realpaths by walking to the deepest existing prefix (find_real_prefix), canonicalizing that prefix, then re-attaching the non-existent suffix. The prefix is guaranteed to exist, so cached_canonicalize failing means the OS refused realpath on an existing path: symlink loop (ELOOP), permission denied traversing a symlinked component (EACCES), I/O error, or a race where the path vanished between the exists() check and canonicalize.","triggerScenarios":"A symlink cycle (a -> b -> a) inside the project or an ancestor; a symlink chain whose resolution needs permissions the user lacks; NFS/automount returning EIO; concurrent deletion making the prefix disappear mid-resolution.","commonSituations":"Monorepos with circular symlinks generated by tooling (pnpm-style links, yarn workspaces hacks); shared machines where a parent dir is traversable but a link target is not; editor/file-watcher activity deleting files while flow resolves paths.","solutions":["Reproduce with readlink -f <path from the panic> to see where resolution breaks","Remove or fix looping/broken symlinks in the reported path (find -type l and inspect)","Fix traversal permissions on symlink targets along the path","Retry after stopping processes that were deleting/moving files, if it was a race"],"exampleFix":"# before\nln -s b a; ln -s a b   # cycle inside the repo\nflow check              # panics: Realpath failed for existent path <prefix>\n\n# after\nrm a b\nflow check","handlingStrategy":"validation","validationCode":"# before running flow over a tree with symlinks\nfind . -type l -exec readlink -f {} + 2>&1 | grep -i 'loop\\|too many levels\\|denied' && echo \"fix these symlinks first\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid circular symlinks in repo tooling; validate with readlink -f during setup","Ensure traversal permission on symlink targets and their parents","Minimize concurrent delete/move churn while flow is resolving paths"],"tags":["filesystem","symlink","realpath","race-condition"],"backgroundTag":"realpath-resolution-failed","analyzedSha":"5c865861998a8ccb7dbc82b0c1f511e9ef60c3d9","analyzedAt":"2026-08-20T10:41:37.992Z","contentChangedAt":"2026-08-20T10:41:37.992Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}