{"record":{"id":"fdbf8191504187d7","repo":"nikivdev/code","slug":"path-must-be-a-directory","errorCode":null,"errorMessage":"Path must be a directory: {}","messagePattern":"Path must be a directory: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ext.rs","lineNumber":139,"sourceCode":"fn disable_extension(name: &str) -> Result<()> {\n    flow_config::disable_extension(name)?;\n    println!(\"Disabled extension {}\", name);\n    Ok(())\n}\n\nfn init_extension(name: &str, force: bool) -> Result<()> {\n    let dir = flow_config::init_extension(name, force)?;\n    println!(\"Initialized extension {} at {}\", name, dir.display());\n    Ok(())\n}\n\nfn import_external_path(path: &str) -> Result<()> {\n    let source = normalize_path(path)?;\n    if !source.exists() {\n        bail!(\"Path not found: {}\", source.display());\n    }\n    if !source.is_dir() {\n        bail!(\"Path must be a directory: {}\", source.display());\n    }\n\n    let project_root = project_root_from_cwd();\n    let ext_dir = project_root.join(\"ext\");\n    fs::create_dir_all(&ext_dir)?;\n\n    let name = source\n        .file_name()\n        .and_then(|n| n.to_str())\n        .map(|s| s.to_string())\n        .filter(|s| !s.trim().is_empty())\n        .unwrap_or_else(|| \"external\".to_string());\n\n    let dest = ext_dir.join(&name);\n    if dest.exists() {\n        bail!(\"Destination already exists: {}\", dest.display());\n    }\n","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ext.rs#L121-L157","documentation":"import_external_path imports an external project directory into the current project's ext/ folder. After normalize_path and an existence check, it requires the path to be a directory; a plain file is rejected because the import copies a whole workspace tree, not individual files.","triggerScenarios":"Calling import_external_path with a path that exists on disk but is a regular file, e.g. import_external_path(\"./config.toml\") or a symlink resolving to a file.","commonSituations":"Passing a config file or lockfile instead of the project folder; shell tab-completion selecting a file; pointing at a nested file inside the repo you meant to import.","solutions":["Pass the directory containing the project/workspace, not a file inside it.","If you meant a subdirectory of a repo, give the repo root or workspace directory.","Verify with `ls -la <path>` that the target is a directory before running the import."],"exampleFix":"// before\nimport_external_path(\"./myproject/Cargo.toml\")?;\n// after\nimport_external_path(\"./myproject\")?;","handlingStrategy":"validation","validationCode":"let p = std::path::Path::new(path);\nif !p.exists() || !p.is_dir() {\n    return Err(anyhow!(\"{} must be an existing directory\", p.display()));\n}\nimport_external_path(path)?;","typeGuard":"fn is_importable_dir(p: &str) -> bool {\n    std::path::Path::new(p).is_dir()\n}","tryCatchPattern":"match import_external_path(path) {\n    Ok(()) => {},\n    Err(e) if e.to_string().starts_with(\"Path must be a directory\") => {\n        eprintln!(\"Pass a directory, not a file: {path}\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Resolve symlinks (canonicalize) before checking the path kind.","Add an is_dir() assertion in scripts that invoke the import command.","Prefer directory pickers/autocomplete limited to directories."],"tags":["filesystem","path-validation","cli"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}