From 2533b0cf879d39ea13ae9c80f5d97ec3aa2d3e1d Mon Sep 17 00:00:00 2001 From: not-matthias Date: Thu, 18 Jun 2026 17:27:06 +0200 Subject: [PATCH] fix(valgrind): honor locally-installed valgrind on non-apt systems --- src/executor/helpers/apt.rs | 2 +- src/executor/valgrind/setup.rs | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/executor/helpers/apt.rs b/src/executor/helpers/apt.rs index 75bec936..29a1d5c3 100644 --- a/src/executor/helpers/apt.rs +++ b/src/executor/helpers/apt.rs @@ -6,7 +6,7 @@ use std::process::Command; const METADATA_FILENAME: &str = "./tmp/codspeed-cache-metadata.txt"; -fn is_system_compatible(system_info: &SystemInfo) -> bool { +pub fn is_system_compatible(system_info: &SystemInfo) -> bool { matches!(system_info.os, SupportedOs::Linux(ref distro) if distro.is_supported()) } diff --git a/src/executor/valgrind/setup.rs b/src/executor/valgrind/setup.rs index d5f75e44..21c32240 100644 --- a/src/executor/valgrind/setup.rs +++ b/src/executor/valgrind/setup.rs @@ -173,11 +173,22 @@ fn classify_valgrind_version(version: String) -> ToolInstallStatus { ToolInstallStatus::Installed { version } } -fn is_valgrind_installed() -> bool { - matches!( +fn is_valgrind_installed(system_info: &SystemInfo) -> bool { + if !matches!( get_valgrind_status().status, ToolInstallStatus::Installed { .. } - ) && apt::is_package_installed("libc6-dbg") + ) { + return false; + } + + // `libc6-dbg` is only relevant on apt-based systems; on others (e.g. NixOS) + // `dpkg` is absent and would spuriously report it as missing. + if apt::is_system_compatible(system_info) { + apt::is_package_installed("libc6-dbg") + } else { + debug!("Skipping libc6-dbg check on non-apt-based system"); + true + } } pub async fn install_valgrind( @@ -187,7 +198,7 @@ pub async fn install_valgrind( apt::install_cached( system_info, setup_cache_dir, - is_valgrind_installed, + || is_valgrind_installed(system_info), || async { debug!("Installing valgrind"); let binary = get_codspeed_valgrind_binary(system_info)?;