nikivdev/code · error

package name is required

Error message

package name is required

What it means

install_with_flox requires a package name to hand to flox. It reads opts.name, trims it, and if it is empty (None or whitespace) bails with 'package name is required'. This is a guard before building the FloxInstallSpec and shelling out to flox.

Source

Thrown at src/install.rs:166

        println!("Would index {} packages into Typesense.", all_entries.len());
        return Ok(());
    }

    typesense_ensure_collection(&config)?;
    typesense_import(&config, all_entries.values().cloned().collect())?;
    println!("Indexed {} packages into Typesense.", all_entries.len());
    Ok(())
}

fn registry_configured(_opts: &InstallOpts) -> bool {
    // Registry is always available — defaults to https://myflow.sh
    true
}

fn install_with_flox(opts: &InstallOpts) -> Result<()> {
    let name = opts.name.as_deref().unwrap_or("").trim();
    if name.is_empty() {
        bail!("package name is required");
    }

    let install_root = tool_root()?;
    let flox_pkg = resolve_flox_pkg_name(name);
    let spec = FloxInstallSpec {
        pkg_path: flox_pkg.to_string(),
        pkg_group: Some("tools".to_string()),
        version: opts.version.clone(),
        systems: None,
        priority: None,
    };

    ensure_flox_tools_env(&install_root, &[(flox_pkg.to_string(), spec)])?;

    let bin_name = opts.bin.clone().unwrap_or_else(|| name.to_string());
    let bin_dir = opts.bin_dir.clone().unwrap_or_else(default_bin_dir);
    fs::create_dir_all(&bin_dir)
        .with_context(|| format!("failed to create {}", bin_dir.display()))?;

View on GitHub (pinned to a747e741ae)

Solutions

  1. Provide a package name: `f install ripgrep`.
  2. Check CLI argument order — ensure the name is not swallowed by another flag's value.
  3. In programmatic use, validate opts.name is Some(non-empty trimmed string) before calling install.
  4. If auto backend selection ran, note install_with_flox is the final backend; supplying a name fixes all backends.

Example fix

// before
InstallOpts { name: None, .. }
// after
InstallOpts { name: Some("ripgrep".into()), .. }
Defensive patterns

Strategy: validation

Validate before calling

let name = opts.name.as_deref().unwrap_or("").trim();
if name.is_empty() {
    eprintln!("usage: f install <package-name>");
    return;
}

Type guard

fn has_package_name(opts: &InstallOpts) -> bool {
    opts.name.as_deref().map(|n| !n.trim().is_empty()).unwrap_or(false)
}

Try / catch

match f_install(name_opt) {
    Err(e) if e.to_string() == "package name is required" => {
        eprintln!("supply a package name, e.g. f install ripgrep");
    }
    r => r?,
}

Prevention

When it happens

Trigger: Calling install_with_flox (directly or via install_with_auto, both reached from run) with InstallOpts whose name is None, empty string, or only whitespace.

Common situations: Running `f install` without a package argument; CLI parsing leaves name unset when a flag consumed the value; programmatic callers construct InstallOpts with a name that is blank after trimming.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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