Skip to content

fix: cache file path corruption when package name contains dots#5668

Merged
baszalmstra merged 1 commit intoprefix-dev:mainfrom
ytausch:fix/cache-dot-in-package-name
Mar 16, 2026
Merged

fix: cache file path corruption when package name contains dots#5668
baszalmstra merged 1 commit intoprefix-dev:mainfrom
ytausch:fix/cache-dot-in-package-name

Conversation

@ytausch
Copy link
Contributor

@ytausch ytausch commented Mar 13, 2026

Description

PathBuf::with_extension("json") in MetadataCache::cache_file_path replaces everything after the last dot in the file name. When a package name contains a dot (e.g., my.package), the source metadata cache hash key becomes something like source-dir/my.package-osx-arm64-HASH, and with_extension("json") truncates it to source-dir/my.json — discarding the platform and hash entirely.

This causes requests for different platforms (e.g., osx-arm64 and linux-64) to read/write the same cache file, producing spurious "Cache was updated by another process" warnings due to version conflicts.

The fix uses string concatenation (format!("{}.json", ...)) instead of with_extension to append the .json suffix, preserving the full file name.

Fixes #5626

How Has This Been Tested?

  • Added a unit test (test_cache_file_path_with_dots_in_key) that verifies cache file paths are correctly generated both with and without dots in the hash key.
  • All existing tests pass (cargo test -p pixi_command_dispatcher — 21 passed).

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.

Tools: Claude Code (Claude Opus 4.6)

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added sufficient tests to cover my changes.

`PathBuf::with_extension("json")` replaces everything after the last
dot in the file name. When a package name contains a dot (e.g.,
"my.package"), the cache hash key becomes something like
"source-dir/my.package-osx-arm64-HASH", and `with_extension` truncates
it to "source-dir/my.json", discarding the platform and hash.

This causes all platforms to write to the same cache file, producing
spurious "Cache was updated by another process" warnings.

Fix by using string concatenation (`format!("{}.json", ...)`) instead
of `with_extension` to append the `.json` suffix.

Closes prefix-dev#5626

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@baszalmstra baszalmstra merged commit c3aec7e into prefix-dev:main Mar 16, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cache was updated by another process warning when using pixi build

3 participants