refactor: simplify pixi run platform resolution, make implicit install platform sticky in core#6509
Open
wolfv wants to merge 2 commits into
Open
refactor: simplify pixi run platform resolution, make implicit install platform sticky in core#6509wolfv wants to merge 2 commits into
wolfv wants to merge 2 commits into
Conversation
The pre-loop block computed a "run platform" from the top-level environment (--platform, else the platform the default/-e environment was last installed for) and validated --platform membership against that environment only. But tasks execute in their own environments, so the block's answers applied to the wrong environment whenever a task lived elsewhere: the membership error was skipped for the environment that actually runs the task (yielding a misleading "no platform supported by it matches the current system" later), and the "assuming platform" log could name a platform the task's environment never uses. Resolve --platform membership per executable task, next to the existing per-task runnability check, and drop the now log-only locals. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pixi run kept an environment on the platform it was last installed for by mutating the global LockFileDerivedData::target_platform override per task environment inside its execution loop -- shared mutable state standing in for a per-environment decision, and stickiness that other prefix consumers (pixi shell, pixi install) never got, so they could silently flip a prefix that was deliberately installed for another declared platform. Move the stickiness into LockFileDerivedData::install_platform: with no explicit --platform override, prefer the platform recorded in the environment's conda-meta/pixi marker (when the environment still declares it) over the host's best declared platform. The lock-file hash now also goes through install_platform so it always reflects the platform an install would actually target. target_platform is back to meaning only the explicit --platform flag, and pixi run's loop mutation disappears. Task search already preferred the installed platform with the same env-membership guard; share it via the new Environment::installed_declared_platform. Note the deliberate behavior change outside pixi run: a plain pixi install / pixi shell now keeps a prefix on the declared platform it was last installed for instead of re-targeting the host's best match; pass --platform to re-target. Unlike an explicit --platform, the sticky platform still runs the lock-file minimum-requirements validation, so a prefix the machine can no longer run errors at install time instead of installing and failing afterwards. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
4046ed9 to
69d2b11
Compare
hunger
requested changes
Jul 3, 2026
hunger
left a comment
Contributor
There was a problem hiding this comment.
I like the sticky platform, but I do see a problem with how the "can this run here?" validation works now: a deliberately cross-installed prefix goes from "silently re-targeted, succeeds" to "errors on every install until you repeat --platform or re-set override vars". This is a behavior change we should clear with @ruben-arts first. If we decide to go for this behavior change: We would need tests to hammer this behavior down.
I also am not too happy that we detect errors now only after the lockfile was re-resolved (and maybe rewritten). IMHO we should leave the lockfile alone when we error.
Like all AI code, the code could be DRYer as well. E.g. Some errors are just copied verbatim.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the sibling-environment platform leak fix (
ffe170647/deaf45a63); stacked on those commits, so this shows them until that PR merges — only the top two commits are new.refactor(run): resolve run platform per task environment, not up front
The pre-loop block in
run.rscomputed a "run platform" from the top-level environment (--platform, else the platform the default/-eenvironment was last installed for) and validated--platformmembership against that environment only. But tasks execute in their own environments, so those answers applied to the wrong environment whenever a task lived elsewhere.--platformmembership is now checked per executable task against the environment the task actually runs in, next to the existing runnability check, and the now log-only locals (installed_platform,run_platform,best_declared_platform) are gone. This also fixes a UX gap:pixi run --platform X task-in-gpu-envnow errors withplatform 'X' is not part of environment 'gpu'instead of the misleading "no platform supported by it matches the current system".refactor(install): make the implicit install platform sticky in core
pixi runkept an environment on the platform it was last installed for by mutating the globalLockFileDerivedData::target_platformoverride per task environment inside its execution loop — shared mutable state standing in for a per-environment decision, and stickiness that other prefix consumers (pixi shell,pixi install) never got, so they could silently flip a prefix that was deliberately installed for another declared platform.The stickiness now lives in
LockFileDerivedData::install_platform: with no explicit--platform, prefer the platform recorded in the environment'sconda-meta/piximarker (when the environment still declares it) over the host's best declared platform. The lock-file hash also goes throughinstall_platform, so hash and install can no longer disagree.target_platformis back to meaning only the explicit--platformflag.Task search already preferred the installed platform with the same env-membership guard; both now share the new
Environment::installed_declared_platform, and the deadinstalled_resolved_platform_nameis removed.Deliberate behavior changes
pixi install/pixi shellnow keeps a prefix on the declared platform it was last installed for instead of re-targeting the host's best match; pass--platformto re-target.--platform, the sticky platform still runs the lock-file minimum-requirements validation, so a prefix the machine can no longer run errors at install time instead of installing and failing afterwards.🤖 Generated with Claude Code