nikivdev/code · error
flox search failed: {}
Error message
flox search failed: {} What it means
flox_search shells out to the flox binary (`flox search -a <query>`) expecting JSON on stdout. If the binary exits non-zero, its trimmed stderr is wrapped into 'flox search failed: <stderr>'. The underlying cause is whatever flox printed — auth issues, network failures, bad channel config, or unknown flags.
Source
Thrown at src/install.rs:893
.map(|d| d.to_ascii_lowercase().contains(&query.to_ascii_lowercase()))
.unwrap_or(false)
{
return (2, entry.pkg_path.clone());
}
(3, entry.pkg_path.clone())
}
fn flox_search(flox_bin: &Path, query: &str) -> Result<Vec<FloxSearchEntry>> {
let output = std::process::Command::new(flox_bin)
.arg("search")
.arg("--json")
.arg("-a")
.arg(query)
.output()
.with_context(|| format!("failed to run flox search {}", query))?;
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
bail!("flox search failed: {}", stderr.trim());
}
let stdout =
String::from_utf8(output.stdout).context("flox search output was not valid UTF-8")?;
let entries: Vec<FloxSearchEntry> = serde_json::from_str(&stdout)
.with_context(|| format!("failed to parse flox search output for {}", query))?;
Ok(entries)
}
fn prompt_line(message: &str, default: Option<&str>) -> Result<String> {
if let Some(default) = default {
print!("{message} [{default}]: ");
} else {
print!("{message}: ");
}
io::stdout().flush()?;
let mut input = String::new();
io::stdin().read_line(&mut input)?;
let trimmed = input.trim();View on GitHub (pinned to a747e741ae)
Solutions
- Read the stderr in the message — it contains flox's own diagnostic
- Run `flox search -a <query>` manually to reproduce and see the full error
- Run `flox auth login` if the stderr indicates authentication issues
- Update or reinstall flox if flags/JSON output format changed in your version; also verify resolve_flox_bin picks the intended binary
Defensive patterns
Strategy: fallback
Validate before calling
// preflight: flox binary present and supports the flags
let probe = std::process::Command::new(&flox_bin).arg("--version").output()?;
if !probe.status.success() {
bail!("flox binary at {} is not runnable", flox_bin);
} Try / catch
match flox_search_with_aliases(&flox_bin, query) {
Err(e) if e.to_string().starts_with("flox search failed") => {
eprintln!("flox CLI search failed: {} — check login/network/flox version", e);
}
other => other?,
} Prevention
- Keep flox installed, on PATH, and up to date
- Run `flox auth login` when the stderr indicates auth problems
- Pin a flox version compatible with the `search -a` JSON output format
- Verify network/proxy access to the flox catalog
When it happens
Trigger: `flox search -a <query>` returns non-zero: flox not authenticated/logged in, no network to the flox catalog, invalid flake/channel configuration, or a flox version whose CLI doesn't support the flags used.
Common situations: flox not installed or stale version with different CLI flags; corporate proxy blocking catalog access; corrupted flox environment; running in a directory where flox can't resolve configuration.
Related errors
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/ba2c60babb365b3f.
Report an issue: GitHub.