{"record":{"id":"c1f96d1a52b72366","repo":"nikivdev/code","slug":"package-name-is-required","errorCode":null,"errorMessage":"package name is required","messagePattern":"package name is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/install.rs","lineNumber":166,"sourceCode":"        println!(\"Would index {} packages into Typesense.\", all_entries.len());\n        return Ok(());\n    }\n\n    typesense_ensure_collection(&config)?;\n    typesense_import(&config, all_entries.values().cloned().collect())?;\n    println!(\"Indexed {} packages into Typesense.\", all_entries.len());\n    Ok(())\n}\n\nfn registry_configured(_opts: &InstallOpts) -> bool {\n    // Registry is always available — defaults to https://myflow.sh\n    true\n}\n\nfn install_with_flox(opts: &InstallOpts) -> Result<()> {\n    let name = opts.name.as_deref().unwrap_or(\"\").trim();\n    if name.is_empty() {\n        bail!(\"package name is required\");\n    }\n\n    let install_root = tool_root()?;\n    let flox_pkg = resolve_flox_pkg_name(name);\n    let spec = FloxInstallSpec {\n        pkg_path: flox_pkg.to_string(),\n        pkg_group: Some(\"tools\".to_string()),\n        version: opts.version.clone(),\n        systems: None,\n        priority: None,\n    };\n\n    ensure_flox_tools_env(&install_root, &[(flox_pkg.to_string(), spec)])?;\n\n    let bin_name = opts.bin.clone().unwrap_or_else(|| name.to_string());\n    let bin_dir = opts.bin_dir.clone().unwrap_or_else(default_bin_dir);\n    fs::create_dir_all(&bin_dir)\n        .with_context(|| format!(\"failed to create {}\", bin_dir.display()))?;","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/install.rs#L148-L184","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Provide a package name: `f install ripgrep`.","Check CLI argument order — ensure the name is not swallowed by another flag's value.","In programmatic use, validate opts.name is Some(non-empty trimmed string) before calling install.","If auto backend selection ran, note install_with_flox is the final backend; supplying a name fixes all backends."],"exampleFix":"// before\nInstallOpts { name: None, .. }\n// after\nInstallOpts { name: Some(\"ripgrep\".into()), .. }","handlingStrategy":"validation","validationCode":"let name = opts.name.as_deref().unwrap_or(\"\").trim();\nif name.is_empty() {\n    eprintln!(\"usage: f install <package-name>\");\n    return;\n}","typeGuard":"fn has_package_name(opts: &InstallOpts) -> bool {\n    opts.name.as_deref().map(|n| !n.trim().is_empty()).unwrap_or(false)\n}","tryCatchPattern":"match f_install(name_opt) {\n    Err(e) if e.to_string() == \"package name is required\" => {\n        eprintln!(\"supply a package name, e.g. f install ripgrep\");\n    }\n    r => r?,\n}","preventionTips":["Pass the package name positionally and unquoted-empty: f install <name>","In scripts, require the argument with ${1:?package name required}","Validate InstallOpts.name is a non-empty trimmed string before calling install APIs"],"tags":["input-validation","cli","install"],"backgroundTag":"missing-required-argument","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}