nikivdev/code · error
No branches available to search
Error message
No branches available to search
What it means
`run_find` (src/branches.rs:57) collects local (or remote, if requested) git branches and bails if the resulting list is empty. There is nothing to search, so the find operation aborts before ranking.
Solutions
- Run the command from inside a git repository that has branches
- If using --remote, run `git fetch --all` first so remote refs exist
- Verify the remote is configured (`git remote -v`)
- Drop the --remote flag to search local branches
Defensive patterns
Strategy: validation
Validate before calling
// ensure we're in a repo with refs before running find
let out = std::process::Command::new("git").args(["rev-parse", "--is-inside-work-tree"]).output()?;
if !out.status.success() {
anyhow::bail!("not inside a git repository");
} Type guard
fn branches_available(b: &[Branch]) -> bool { !b.is_empty() } Try / catch
match run_find(opts) {
Err(e) if e.to_string().contains("No branches available") => {
eprintln!("run inside a repo with branches, or `git fetch --all` first");
}
other => other?,
} Prevention
- Verify `git branch -a` lists branches in the target directory
- Run `git fetch --all` before remote searches
- Check working directory in scripts/CI before invoking
When it happens
Trigger: `collect_branches(opts.remote)` returns an empty vector — running in a directory with no git repo/branches, or `--remote` set while no remote branches exist (no fetch, no remote configured, or wrong repo).
Common situations: Invoked outside a git repository; fresh clone with zero local branches and no fetched remotes; `--remote` flag used in a repo whose remote hasn't been fetched yet.
Related errors
- No branches available for AI matching
- Commit queue is empty.
- No PR found for current branch and commit queue is empty.
- Commit aborted after auto-fix. Review changes and retry.
- Commit aborted after manual fix. Review changes and retry.
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/d3d14ca4c6860ae3.
Report an issue: GitHub.
Appendix: source
Thrown at src/branches.rs:57
return Ok(());
}
let limit = opts.limit.max(1);
for entry in branches.iter().take(limit) {
print_branch(entry);
}
Ok(())
}
fn run_find(opts: BranchFindOpts) -> Result<()> {
let query = opts.query.trim().to_string();
if query.is_empty() {
bail!("Query cannot be empty");
}
let branches = collect_branches(opts.remote)?;
if branches.is_empty() {
bail!("No branches available to search");
}
let ranked = rank_branches(&query, &branches);
if ranked.is_empty() {
bail!("No branches matched query '{}'.", query);
}
let limit = opts.limit.max(1);
for (_, entry) in ranked.iter().take(limit) {
print_branch(entry);
}
if opts.switch {
let best = ranked
.first()
.map(|(_, entry)| (*entry).clone())
.context("No match available to switch")?;
println!("\nSwitching to {}...", best.name);View on GitHub (pinned to a747e741ae)