{"record":{"id":"921d3639accf955c","repo":"swc-project/swc","slug":"path-does-not-exist","errorCode":null,"errorMessage":"path does not exist: `{}`","messagePattern":"path does not exist: `(.+?)`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbg-swc/src/es/flow/strip.rs","lineNumber":276,"sourceCode":"    {\n        let wr = JsWriter::new(cm.clone(), \"\\n\", &mut buf, None);\n        let mut emitter = Emitter {\n            cfg: CodegenConfig::default(),\n            comments: None,\n            cm,\n            wr,\n        };\n        emitter\n            .emit_program(program)\n            .context(\"failed to emit transformed program\")?;\n    }\n\n    String::from_utf8(buf).context(\"swc emitted non-utf8 output\")\n}\n\nfn collect_flow_files(path: &Path) -> Result<Vec<PathBuf>> {\n    if !path.exists() {\n        bail!(\"path does not exist: `{}`\", path.display());\n    }\n\n    let mut files = Vec::new();\n    let mut stack = vec![path.to_path_buf()];\n\n    while let Some(current) = stack.pop() {\n        if current.is_dir() {\n            let entries = current\n                .read_dir()\n                .with_context(|| format!(\"failed to read directory `{}`\", current.display()))?;\n\n            for entry in entries {\n                let entry = entry.with_context(|| {\n                    format!(\"failed to read an entry in `{}`\", current.display())\n                })?;\n                stack.push(entry.path());\n            }\n            continue;","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/dbg-swc/src/es/flow/strip.rs#L258-L294","documentation":"collect_flow_files starts with an existence check on the supplied path and bails immediately if it does not exist on disk. It is a fail-fast guard before any directory walking happens, so no partial work occurs. The path is displayed verbatim in the message.","triggerScenarios":"Passing a --path that does not resolve: typo, relative path evaluated from a different cwd, deleted directory, or a path inside an uninitialized submodule.","commonSituations":"Running the CLI from a different working directory than assumed; copied commands with absolute paths from another machine; submodule mount points that exist only after 'git submodule update --init'.","solutions":["Check the path exists before running: ls <path> or test -d <path>","Use an absolute path or run the command from the intended working directory","If the target is in a submodule, initialize it first with git submodule update --init --recursive"],"exampleFix":"# before\n$ dbg-swc es flow strip --path ./submodules/flow  # not checked out yet\nerror: path does not exist: `./submodules/flow`\n\n# after\n$ git submodule update --init --recursive\n$ dbg-swc es flow strip --path ./submodules/flow","handlingStrategy":"validation","validationCode":"use std::path::Path;\n\nfn ensure_corpus_dir(path: &str) -> std::io::Result<&Path> {\n    let p = Path::new(path);\n    let meta = std::fs::metadata(p)?; // fails fast with a real io error if missing\n    if !meta.is_dir() {\n        return Err(std::io::Error::new(\n            std::io::ErrorKind::InvalidInput,\n            format!(\"{path} is not a directory\"),\n        ));\n    }\n    Ok(p)\n}","typeGuard":"import fs from 'node:fs';\nconst isUsablePath = (p: string): boolean => {\n  try {\n    return fs.statSync(p).isDirectory();\n  } catch {\n    return false;\n  }\n};","tryCatchPattern":null,"preventionTips":["Resolve --path to an absolute path (fs.realpathSync) before invoking the CLI","Initialize submodules when sources live in one","Wrap CLI invocations in scripts that stat the path first and print a friendly message"],"tags":["dbg-swc","flow","cli","filesystem"],"backgroundTag":"file-not-found","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}