nikivdev/code · error · anyhow::Error

Path not found: {}

Error message

Path not found: {}

What it means

`import_external_path` normalizes the given path and bails if it does not exist on disk. Importing an extension requires an existing directory; this is the first guard before further validation (directory check, project root resolution).

Source

Thrown at src/ext.rs:136

    Ok(())
}

fn disable_extension(name: &str) -> Result<()> {
    flow_config::disable_extension(name)?;
    println!("Disabled extension {}", name);
    Ok(())
}

fn init_extension(name: &str, force: bool) -> Result<()> {
    let dir = flow_config::init_extension(name, force)?;
    println!("Initialized extension {} at {}", name, dir.display());
    Ok(())
}

fn import_external_path(path: &str) -> Result<()> {
    let source = normalize_path(path)?;
    if !source.exists() {
        bail!("Path not found: {}", source.display());
    }
    if !source.is_dir() {
        bail!("Path must be a directory: {}", source.display());
    }

    let project_root = project_root_from_cwd();
    let ext_dir = project_root.join("ext");
    fs::create_dir_all(&ext_dir)?;

    let name = source
        .file_name()
        .and_then(|n| n.to_str())
        .map(|s| s.to_string())
        .filter(|s| !s.trim().is_empty())
        .unwrap_or_else(|| "external".to_string());

    let dest = ext_dir.join(&name);
    if dest.exists() {

View on GitHub (pinned to a747e741ae)

Solutions

  1. Check the path exists: ls <path> from the same directory you run f in
  2. Use an absolute path to rule out cwd confusion: f ext import /abs/path/to/ext
  3. Verify the extension directory name after any rename (check the source repo's extensions folder)
  4. Clone or restore the extension directory if it lives in another repository
  5. Note the next guard: even if it exists, it must be a directory, not a file

Example fix

// before
f ext import ./extenstions/my-ext   # typo, Path not found
// after
f ext import ./extensions/my-ext    # correct directory
Defensive patterns

Strategy: validation

Validate before calling

// verify the import target before running the command
let target = std::path::Path::new("./extensions/my-ext");
let abs = std::fs::canonicalize(target).unwrap_or_else(|_| target.to_path_buf());
if !abs.is_dir() {
    bail!("import target does not exist or is not a directory: {}", abs.display());
}

Try / catch

match result {
    Err(e) if e.to_string().starts_with("Path not found") => {
        eprintln!("{e}; check the path and your working directory");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling `f ext import <path>` (or the bare-path form) where `source.exists()` is false after normalization — relative path wrong relative to cwd, or the directory was deleted/renamed.

Common situations: Typo in the path or wrong working directory; extension folder renamed during refactoring; path given relative to a different directory than the shell's cwd; trailing-slash or symlink issues after normalize_path; trying to import a path from another repo that hasn't been cloned.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/4dab99dd254a1d20. Report an issue: GitHub.