Skip to content

fix: changing package.build.config does not invalidate caches#5371

Merged
ruben-arts merged 7 commits intoprefix-dev:mainfrom
baszalmstra:claude/investigate-and-fix-issue-FhDyh
Jan 21, 2026
Merged

fix: changing package.build.config does not invalidate caches#5371
ruben-arts merged 7 commits intoprefix-dev:mainfrom
baszalmstra:claude/investigate-and-fix-issue-FhDyh

Conversation

@baszalmstra
Copy link
Contributor

@baszalmstra baszalmstra commented Jan 20, 2026

Description

This fixes an issue where changes to [package.build.config] in pixi.toml (such as noarch = true to noarch = false) would not invalidate the metadata cache, causing the lock file to appear up-to-date when it should have been re-solved.

The fix introduces a ConfigurationHash that captures changes to both the configuration and target_configuration fields from the build backend. This hash is now:

  • Computed when creating metadata via call_conda_outputs
  • Stored in CachedCondaMetadata
  • Checked during cache freshness verification in verify_cache_freshness

When the configuration changes, the metadata cache is invalidated, triggering a re-query of the build backend and subsequent lock file update.

Fixes #5309

How Has This Been Tested?

  • A manual check with the reproducer from the issue

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 Opus 4.5

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added sufficient tests to cover my changes.
  • I have verified that changes that would impact the JSON schema have been made in schema/model.py.

claude and others added 2 commits January 20, 2026 12:58
This fixes an issue where changes to `[package.build.config]` in pixi.toml
(such as `noarch = true` to `noarch = false`) would not invalidate the
metadata cache, causing the lock file to appear up-to-date when it
should have been re-solved.

The fix introduces a `ConfigurationHash` that captures changes to both
the `configuration` and `target_configuration` fields from the build
backend. This hash is now:
- Computed when creating metadata via `call_conda_outputs`
- Stored in `CachedCondaMetadata`
- Checked during cache freshness verification in `verify_cache_freshness`

When the configuration changes, the metadata cache is invalidated,
triggering a re-query of the build backend and subsequent lock file
update.

Fixes prefix-dev#5309
@baszalmstra baszalmstra marked this pull request as ready for review January 20, 2026 15:48
Copy link
Contributor

@Hofer-Julian Hofer-Julian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Would be great to have a test for this though

Copy link
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected, added two small nitpicks.

Adds a test that verifies changing `[package.build.config]` correctly
invalidates the metadata cache and causes the build backend to be
re-queried.

The test uses ObservableBackend to verify that:
1. The backend is called once for initial lock file generation
2. The backend is NOT called again when nothing changes (cache hit)
3. The backend IS called again when `[package.build.config]` changes
4. The backend is NOT called again after the cache is updated

This tests the fix for issue prefix-dev#5309.
@baszalmstra baszalmstra force-pushed the claude/investigate-and-fix-issue-FhDyh branch from e949513 to 7d2d168 Compare January 20, 2026 16:19
Changed ConfigurationHash::compute to always return a hash value instead
of Option<Self>. This simplifies the API and ensures consistent behavior
whether configs are empty or not. Added Default impl for backward
compatibility with existing cache files.
Extended test_build_config_change_invalidates_cache to verify that:
1. Starting with no [package.build.config] section works
2. Adding an empty [package.build.config] section does NOT invalidate
   the cache (empty config hashes the same as no config)
3. Adding actual config values DOES invalidate the cache
4. Changing config values also invalidates the cache
@baszalmstra
Copy link
Contributor Author

@ruben-arts Should work now!
@Hofer-Julian I added a test too!

@ruben-arts
Copy link
Contributor

diff --git a/examples/pixi-build/cpp-sdl/pixi.toml b/examples/pixi-build/cpp-sdl/pixi.toml
index 868ed770c..4a52af73c 100644
--- a/examples/pixi-build/cpp-sdl/pixi.toml
+++ b/examples/pixi-build/cpp-sdl/pixi.toml
@@ -32,6 +32,7 @@ channels = [
 name = "pixi-build-cmake"
 version = "0.3.*"
 
+[package.build.config]
 
 [package.host-dependencies]
 # This ensures that SDL2 is available at build time.

This will still trigger a rebuild.

@baszalmstra
Copy link
Contributor Author

@ruben-arts Are you sure you cleared the cache? There is a test that literally checks that.

@baszalmstra
Copy link
Contributor Author

Copy link
Contributor

@Hofer-Julian Hofer-Julian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@baszalmstra
Copy link
Contributor Author

@ruben-arts I just tried it myself and it seems to work for me!

@ruben-arts
Copy link
Contributor

@ruben-arts Are you sure you cleared the cache? There is a test that literally checks that.

I did recheck with clean cache (rm -rf examples/cpp-sdl/.pixi) and rebuild of pixi itself, I can't make it work as expected. It seems like the test is only checking the lockfile satisfiablity but not te rebuilding request.

Maybe this reproducer helps:

pixi install
# First build 👍 
pixi install
# Cached everything 👍 

echo "[package.build.config]" >> pixi.toml

pixi lock
# Statisfied 👍 

pixi install
# Unexpected Rebuild 👎 

Replaced the single PackageBuildInputHash in CachedBuildSourceInfo with
separate project_model_hash and configuration_hash fields. This aligns
the build cache with the metadata cache structure, using the same hash
types (ProjectModelHash and ConfigurationHash) for both caching systems.

Removed PackageBuildInputHash and PackageBuildInputHashBuilder as they
are no longer needed.
@baszalmstra baszalmstra force-pushed the claude/investigate-and-fix-issue-FhDyh branch from 481bfd1 to 2ff419c Compare January 21, 2026 10:43
@baszalmstra
Copy link
Contributor Author

@ruben-arts OKE! Should be good now. :) All caches now use the same mechanism for the configuration.

@ruben-arts ruben-arts merged commit 26f056f into prefix-dev:main Jan 21, 2026
37 checks passed
@ruben-arts ruben-arts deleted the claude/investigate-and-fix-issue-FhDyh branch January 21, 2026 12:35
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.

Changing package.build.config does not invalidate caches

4 participants