Skip to content

fix: include variants when calculating cache key#5167

Merged
baszalmstra merged 9 commits intoprefix-dev:mainfrom
nichmor:fix/include-variants-when-calculating-cache-key
Dec 19, 2025
Merged

fix: include variants when calculating cache key#5167
baszalmstra merged 9 commits intoprefix-dev:mainfrom
nichmor:fix/include-variants-when-calculating-cache-key

Conversation

@nichmor
Copy link
Contributor

@nichmor nichmor commented Dec 18, 2025

Description

The problem was that we did not take into account variants when searching for a cached source build, so we would pick up another one and omit the building part.

Fixes: #4139

How Has This Been Tested?

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

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.

Copy link
Contributor

@baszalmstra baszalmstra left a comment

Choose a reason for hiding this comment

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

Every test does rhis now. Since you only need it for one test, best to create a mockdatabase specifically for that.

@baszalmstra
Copy link
Contributor

With this I mean the materialization of sdl2

fs_err::create_dir_all(&info_dir)?;

// Write index.json
let index_json_content = serde_json::to_string_pretty(index_json)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

When you create the outputs from conda_outputs you augment the information from the index.json. That should also happen here, otherwise they dont represent the same thing.


/// The specific variant values for this build. Different variants result
/// in different cache keys to ensure they are cached separately.
pub variants: Option<BTreeMap<String, VariantValue>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should not be an option. Variants are always present.

@baszalmstra
Copy link
Contributor

baszalmstra commented Dec 19, 2025

This error :

thread 'test_stale_host_dependency_triggers_rebuild' panicked at crates\pixi_command_dispatcher\tests\integration\main.rs:500:10:
called `Result::unwrap()` on an `Err` value: "  
× failed to build 'package-b' from 'package-b'
  ╰─▶   × The build backend did not return the expected package: noarch/package-b=0.1.0=h4616a5c_0. Instead the build backend returned noarch/package-b=0.1.0=h4616a5c_0_d4994e8f."

Indicates that you return different data from conda/outputs then what you do in conda/build. Please try to consolidate that behavior as much as possible.

@baszalmstra baszalmstra merged commit 75a9d0e into prefix-dev:main Dec 19, 2025
37 checks passed
ruben-arts pushed a commit to ruben-arts/pixi that referenced this pull request Dec 22, 2025
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.

Installing different variants does not trigger a rebuild

2 participants