jdx/mise · error

apt-cache not found

Error message

apt-cache not found

What it means

The apt-based package provider's `available` check is hard-coded to fail with "apt-cache not found" when the `apt-cache` binary cannot be used, so the provider cannot answer whether package names exist in the APT index.

Solutions

  1. Install apt (and apt-utils) so `apt-cache` is on PATH: `apt-get update && apt-get install -y apt-utils`.
  2. Use the appropriate package provider for your distro (dnf/pacman/brew) instead of the apt provider.
  3. Fix PATH in the environment (especially CI) so /usr/bin is included and `which apt-cache` succeeds.
Defensive patterns

Strategy: fallback

Validate before calling

if which::which("apt-cache").is_err() {
    eprintln!("apt-cache unavailable; skipping apt availability checks");
}

Try / catch

match provider.available(&names).await {
    Err(e) if e.to_string() == "apt-cache not found" => {
        // fall back to another provider or treat as unknown availability
    }
    r => r?,
}

Prevention

When it happens

Trigger: Calling `available(&names)` on the apt provider on a system where `apt-cache` is not installed or not on PATH — i.e. a Debian-family tool layout is assumed but missing (or the code path is exercised on a non-Debian test backend).

Common situations: Running system-package management on a non-Debian Linux (Fedora, Arch) or macOS where apt isn't present; a minimal container image (debian-slim variants) without apt-utils/apt-cache; PATH stripped in CI so the binary isn't found.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/b211acf96815d2d7. Report an issue: GitHub.

Appendix: source

Thrown at src/system/deps.rs:877

        #[async_trait::async_trait(?Send)]
        impl SystemPackageManager for CannotAnswer {
            fn name(&self) -> &str {
                "stub"
            }
            fn is_available(&self) -> bool {
                true
            }
            fn unavailable_reason(&self) -> String {
                unreachable!()
            }
            async fn installed(
                &self,
                _pkgs: &[PackageRequest],
            ) -> crate::result::Result<Vec<crate::system::packages::PackageStatus>> {
                Ok(vec![])
            }
            async fn available(&self, _names: &[String]) -> crate::result::Result<Vec<bool>> {
                eyre::bail!("apt-cache not found")
            }
            async fn install(
                &self,
                _pkgs: &[PackageRequest],
                _opts: &crate::system::packages::InstallOpts,
            ) -> crate::result::Result<()> {
                Ok(())
            }
        }
        let m: Arc<dyn SystemPackageManager> = Arc::new(CannotAnswer);
        let dep = dep_with_packages(vec!["libaio1t64", "libaio1"]);
        assert_eq!(
            resolve_package(&m, &dep).await.as_deref(),
            Some("libaio1t64")
        );
    }

    #[test]

View on GitHub (pinned to 533346cc37)