From a13e3f5f69307da6963bed5d2cab2481bb001f54 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 12 Dec 2024 13:21:35 -0500 Subject: [PATCH] Avoid reusing interpreter metadata when running under Rosetta (#9846) ## Summary Closes https://github.com/astral-sh/uv/issues/9836. --- crates/uv-cache/src/lib.rs | 2 +- crates/uv-python/src/interpreter.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/uv-cache/src/lib.rs b/crates/uv-cache/src/lib.rs index 8090be155afc..c82189d7a42c 100644 --- a/crates/uv-cache/src/lib.rs +++ b/crates/uv-cache/src/lib.rs @@ -784,7 +784,7 @@ impl CacheBucket { Self::SourceDistributions => "sdists-v6", Self::FlatIndex => "flat-index-v2", Self::Git => "git-v0", - Self::Interpreter => "interpreter-v3", + Self::Interpreter => "interpreter-v4", // Note that when bumping this, you'll also need to bump it // in crates/uv/tests/cache_clean.rs. Self::Simple => "simple-v14", diff --git a/crates/uv-python/src/interpreter.rs b/crates/uv-python/src/interpreter.rs index 9dd540e3928d..4c9013aece92 100644 --- a/crates/uv-python/src/interpreter.rs +++ b/crates/uv-python/src/interpreter.rs @@ -1,4 +1,5 @@ use std::borrow::Cow; +use std::env::consts::ARCH; use std::io; use std::path::{Path, PathBuf}; use std::process::{Command, ExitStatus}; @@ -746,7 +747,9 @@ 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, // 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)),