{"record":{"id":"eca7ca972f1cb62e","repo":"nikivdev/code","slug":"no-repo-or-flow-project-found-for","errorCode":null,"errorMessage":"no repo or flow project found for {}","messagePattern":"no repo or flow project found for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/repo_capsule.rs","lineNumber":294,"sourceCode":"}\n\nfn refresh_capsule_for_root(store_dir: &Path, root: &Path) -> Result<RepoCapsule> {\n    let capsule = build_capsule(root)?;\n    save_capsule(store_dir, &capsule)?;\n    Ok(capsule)\n}\n\nfn resolve_target_path(path: Option<&str>) -> Result<PathBuf> {\n    let base = match path.map(str::trim).filter(|value| !value.is_empty()) {\n        Some(value) => config::expand_path(value),\n        None => std::env::current_dir().context(\"read current dir\")?,\n    };\n    Ok(base.canonicalize().unwrap_or(base))\n}\n\nfn resolve_reference_root(path: &Path) -> Result<PathBuf> {\n    let Some(root) = detect_reference_root(path) else {\n        bail!(\"no repo or flow project found for {}\", path.display());\n    };\n    Ok(root)\n}\n\nfn resolve_candidate_root(target_path: &Path, candidate: &str) -> Option<PathBuf> {\n    let trimmed = candidate.trim();\n    if trimmed.is_empty() {\n        return None;\n    }\n\n    let expanded = if trimmed.starts_with(\"~/\") {\n        config::expand_path(trimmed)\n    } else if Path::new(trimmed).is_absolute() {\n        PathBuf::from(trimmed)\n    } else if trimmed.starts_with(\"./\") || trimmed.starts_with(\"../\") {\n        target_path.join(trimmed)\n    } else {\n        return None;","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/repo_capsule.rs#L276-L312","documentation":"resolve_reference_root tries to detect a repository or flow project root for a given path (via detect_reference_root). If neither a git repo nor a flow project can be identified for that path, it bails. Capsule operations (load/refresh, alias setting) require such a root to anchor their state.","triggerScenarios":"Calling `f capsule` load/refresh or setting an alias from a path outside any git repository and outside any flow project.","commonSituations":"Running the command in a plain directory (e.g. /tmp or home); being inside a subdirectory whose parents contain no .git or flow marker; typos in a path argument.","solutions":["cd into a directory inside a git repository (or a flow project) and retry","Initialize a repo/project at the intended location (`git init` or the flow project equivalent)","Pass an explicit correct path if the tool accepts one"],"exampleFix":"// before\ncd /tmp && f capsule refresh\n// after\ncd ~/code/my-project && f capsule refresh","handlingStrategy":"validation","validationCode":"const { execSync } = require(\"child_process\");\nfunction insideRepoOrFlowProject(dir) {\n  try { execSync(\"git rev-parse --show-toplevel\", { cwd: dir, stdio: \"ignore\" }); return true; }\n  catch { return false; } // add flow-project marker check if applicable\n}\nif (!insideRepoOrFlowProject(process.cwd())) throw new Error(\"run this from inside a git repo or flow project\");","typeGuard":null,"tryCatchPattern":"try {\n  run([\"f\", \"capsule\", \"refresh\"]);\n} catch (e) {\n  if (String(e).startsWith(\"no repo or flow project found\")) {\n    console.error(\"cd into a git repo or flow project first.\");\n  } else throw e;\n}","preventionTips":["Only run capsule/alias commands from inside a git repository or flow project","Check for a .git (or flow project marker) in the current directory or ancestors before invoking","Initialize the project (`git init`) if the directory is meant to be one"],"tags":["filesystem","repository","project-root"],"backgroundTag":"no-repo-root-found","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}