Skip to main content

get_installed_versions

Function get_installed_versions 

Source
pub fn get_installed_versions() -> HashMap<String, String>
Expand description

What: Retrieve the versions of all installed packages in one pacman invocation.

Inputs:

  • (none): Invokes pacman -Q to list every installed package with its version.

Output:

  • Map from package name to installed version (revision suffix stripped, e.g. 1.2.3-1 -> 1.2.3, matching get_installed_version).
  • Empty map on failure (graceful degradation).

Details:

  • One subprocess for the whole system — use this instead of calling get_installed_version in a loop (e.g. build-preflight analysis of a long dependency list).
  • Sets LC_ALL=C and LANG=C for consistent locale-independent output.

§Example

use arch_toolkit::deps::get_installed_versions;

let versions = get_installed_versions();
if let Some(version) = versions.get("pacman") {
    println!("pacman {version}");
}