fix(cache): include subdir in CacheKey to prevent cross-platform cache collisions#2167
fix(cache): include subdir in CacheKey to prevent cross-platform cache collisions#2167ritankarsaha wants to merge 1 commit intoconda:mainfrom
Conversation
…lisions Signed-off-by: RITANKAR SAHA <ritankar.saha786@gmail.com> fix(cache): include subdir in CacheKey to prevent cross-platform collisions Signed-off-by: RITANKAR SAHA <ritankar.saha786@gmail.com> fix(cache): include subdir in CacheKey to prevent cross-platform collisions Signed-off-by: RITANKAR SAHA <ritankar.saha786@gmail.com>
887d164 to
123de67
Compare
|
Did you just open the same pr twice with a different description? Edit: nope it was two different people. |
Ahh no, I squashed the 3 commits into one, to make it look cleaner, that's all ! |
|
This is a duplicate of #2165, please see my comment there and figure out amongst yourselves which PR should be merged. |
|
Both PRs suffer from the exact same issue, this one just has more unit tests. But both try to solve the same problem. |
Ahh lemme know, which one you planning to move on with, happy to be of help and use in both @baszalmstra |
|
I dont really care. Maybe you can discuss with the other author how you'd solve my comment? |
Description
Fixes the long-standing TODO in cache_key.rs about non-uniqueness of CacheKey across subdirectories.
Problem
CacheKey was keyed only on name + version + build_string. Two packages from different platforms
(e.g. linux-64 and osx-arm64) with identical coordinates would hash to the same cache entry. The
first one cached would be returned for both, silently installing the wrong architecture.
Solution
subdir, so behavior is unchanged for that path
subdir info) where the caller knows the platform
Fixes #2166
How Has This Been Tested?
6 unit tests has been added to this properly
The critical test is test_cross_platform_keys_are_distinct — it directly exercises the bug scenario
(two packages from linux-64 vs osx-arm64 with identical coordinates) and asserts they produce different cache directory names.
To run just these tests:
pixi run -- cargo nextest run -p rattler_cache cache_key::tests
Checklist:
Breaking change
Cache directory names for PackageRecord-derived keys will include the subdir suffix. Existing
cached entries without the suffix will be treated as misses and re-fetched. This is the correct and
safe behavior.