Skip to main content

get_installed_packages

Function get_installed_packages 

Source
pub fn get_installed_packages() -> Result<HashSet<String>>
Expand description

What: Enumerate all currently installed packages on the system.

Inputs:

  • (none): Invokes pacman -Qq to query the local database.

Output:

  • Returns Ok(HashSet<String>) containing package names installed on the machine.
  • Returns Ok(HashSet::new()) on failure (graceful degradation).

Details:

  • Uses pacman’s quiet format to obtain trimmed names.
  • Logs errors for diagnostics but returns empty set to avoid blocking dependency checks.
  • Sets LC_ALL=C and LANG=C for consistent locale-independent output.

§Errors

This function does not return errors - it gracefully degrades by returning an empty set. Errors are logged using tracing::error for diagnostics.

§Example

use arch_toolkit::deps::get_installed_packages;

let installed = get_installed_packages().unwrap();
println!("Found {} installed packages", installed.len());