diff --git a/Cargo.lock b/Cargo.lock index cd650bede..63dedc89e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5456,6 +5456,7 @@ dependencies = [ "schemars", "serde", "serde_json", + "sys-info", "target-lexicon", "temp-env", "tempfile", diff --git a/crates/uv-python/Cargo.toml b/crates/uv-python/Cargo.toml index 7b9b98d6b..0a26279f9 100644 --- a/crates/uv-python/Cargo.toml +++ b/crates/uv-python/Cargo.toml @@ -51,6 +51,7 @@ same-file = { workspace = true } schemars = { workspace = true, optional = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } +sys-info = { workspace = true } target-lexicon = { workspace = true } tempfile = { workspace = true } thiserror = { workspace = true } diff --git a/crates/uv-python/src/interpreter.rs b/crates/uv-python/src/interpreter.rs index 417d094ee..228bad505 100644 --- a/crates/uv-python/src/interpreter.rs +++ b/crates/uv-python/src/interpreter.rs @@ -848,9 +848,13 @@ impl InterpreterInfo { let cache_entry = cache.entry( CacheBucket::Interpreter, - // Shard interpreter metadata by host architecture, to avoid cache collisions when - // running universal binaries under Rosetta. - ARCH, + // Shard interpreter metadata by host architecture, operating system, and version, to + // invalidate the cache (e.g.) on OS upgrades. + cache_digest(&( + ARCH, + sys_info::os_type().unwrap_or_default(), + sys_info::os_release().unwrap_or_default(), + )), // We use the absolute path for the cache entry to avoid cache collisions for relative // paths. But we don't to query the executable with symbolic links resolved. format!("{}.msgpack", cache_digest(&absolute)),