Skip to content

fix: feature activation environment variable priority#4282

Merged
Hofer-Julian merged 3 commits intoprefix-dev:mainfrom
magentaqin:bugfix/feature-environment-variable-override
Aug 7, 2025
Merged

fix: feature activation environment variable priority#4282
Hofer-Julian merged 3 commits intoprefix-dev:mainfrom
magentaqin:bugfix/feature-environment-variable-override

Conversation

@magentaqin
Copy link
Contributor

This PR is to fix: #4116

What I changed
As self.features() would put "default" envs in the last item, but the "default" env priority should be the lowest.Here, we use rfold (reverse fold) to ensure later features override earlier features for environment variables. Processing features in reverse order means that features appearing later in the list will have higher precedence.
Example: If features: [override_feature, user_feature, default]
rfold processes as: [default, user_feature, override_feature]
Result: override_feature env vars take precedence over all others.

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.

Good catch, one small comment, then we can merge it


[environments]
foo = ["foo"]
cuda = ["cuda"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cuda = ["cuda"]
cuda = ["foo", "cuda"]

This way we ensure that "cuda" indeed has the highest priority

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the tests. but as self.features() returns ["cuda1","cuda2", "default"], rfold result is ["default", "cuda2","cuda1"]. so "cuda1" takes the priority.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense!

@Hofer-Julian Hofer-Julian changed the title fix: fix feature activation environment variable priority fix: feature activation environment variable priority Aug 7, 2025
@Hofer-Julian Hofer-Julian merged commit d06323c into prefix-dev:main Aug 7, 2025
39 checks passed
Hofer-Julian added a commit to Hofer-Julian/pixi that referenced this pull request Aug 14, 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.

Feature environment variables not overriding environment variables in activation.env

2 participants