Skip to content

Commit 3039a71

Browse files
authored
chore: only warn about metadata cache once (#4807)
1 parent 2defc88 commit 3039a71

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/pixi_command_dispatcher/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ fs-err = { workspace = true }
2020
futures = { workspace = true }
2121
itertools = { workspace = true }
2222
miette = { workspace = true }
23+
once_cell = { workspace = true }
2324
ordermap = { workspace = true }
2425
pathdiff = { workspace = true }
2526
pin-project-lite = { workspace = true }

crates/pixi_command_dispatcher/src/build_backend_metadata/mod.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
use std::{
2-
collections::{BTreeMap, BTreeSet},
3-
hash::{Hash, Hasher},
4-
path::PathBuf,
5-
};
6-
71
use miette::Diagnostic;
2+
use once_cell::sync::Lazy;
83
use pathdiff::diff_paths;
94
use pixi_build_discovery::{CommandSpec, EnabledProtocols};
105
use pixi_build_frontend::Backend;
@@ -14,6 +9,12 @@ use pixi_record::{InputHash, PinnedSourceSpec};
149
use pixi_spec::{SourceAnchor, SourceSpec};
1510
use rand::random;
1611
use rattler_conda_types::{ChannelConfig, ChannelUrl};
12+
use std::{
13+
collections::{BTreeMap, BTreeSet, HashSet},
14+
hash::{Hash, Hasher},
15+
path::PathBuf,
16+
sync::Mutex,
17+
};
1718
use thiserror::Error;
1819
use tracing::instrument;
1920
use xxhash_rust::xxh3::Xxh3;
@@ -29,6 +30,18 @@ use crate::{
2930
use pixi_build_discovery::BackendSpec;
3031
use pixi_build_frontend::BackendOverride;
3132

33+
static WARNED_BACKENDS: Lazy<Mutex<HashSet<String>>> = Lazy::new(|| Mutex::new(HashSet::new()));
34+
35+
fn warn_once_per_backend(backend_name: &str) {
36+
let mut warned = WARNED_BACKENDS.lock().unwrap();
37+
if warned.insert(backend_name.to_string()) {
38+
tracing::warn!(
39+
"metadata cache disabled for build backend '{}' (system/path-based backends always regenerate metadata)",
40+
backend_name
41+
);
42+
}
43+
}
44+
3245
/// Represents a request for metadata from a build backend for a particular
3346
/// source location. The result of this request is the metadata for that
3447
/// particular source.
@@ -145,10 +158,7 @@ impl BuildBackendMetadataSpec {
145158
let backend_name = match &discovered_backend.backend_spec {
146159
BackendSpec::JsonRpc(spec) => &spec.name,
147160
};
148-
tracing::warn!(
149-
"metadata cache disabled for build backend '{}' (system/path-based backends always regenerate metadata)",
150-
backend_name
151-
);
161+
warn_once_per_backend(backend_name);
152162
}
153163

154164
// Instantiate the backend with the discovered information.

0 commit comments

Comments
 (0)