Skip to content

Conversation

@Hind-M
Copy link
Member

@Hind-M Hind-M commented May 27, 2025

Fix #3884

As specified in the CEP:

  • The prefix is often ignored (it's the case in conda as well)
  • platforms and category are optional and are mostly used by tools that generate lockfiles.

Therefore, those are not considered in mamba.

This PR handles the missing key variables corresponding to the environment variables to be set upon environment activation (through state file).

@Hind-M Hind-M added the release::bug_fixes For PRs fixing bugs label May 27, 2025
@codecov
Copy link

codecov bot commented May 27, 2025

Codecov Report

Attention: Patch coverage is 17.94872% with 32 lines in your changes missing coverage. Please review.

Project coverage is 63.61%. Comparing base (a1a6760) to head (b660b03).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
libmamba/src/api/install.cpp 9.37% 29 Missing ⚠️
libmamba/src/api/create.cpp 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3955      +/-   ##
==========================================
- Coverage   63.66%   63.61%   -0.05%     
==========================================
  Files         303      303              
  Lines       37968    38005      +37     
  Branches     2828     2835       +7     
==========================================
+ Hits        24171    24178       +7     
- Misses      13742    13772      +30     
  Partials       55       55              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Hind-M Hind-M marked this pull request as ready for review May 27, 2025 12:45
@Hind-M
Copy link
Member Author

Hind-M commented May 27, 2025

Would rebase after merging #3956 to avoid issues locally (if changes are requested for this PR).

Copy link
Member

@jjerphan jjerphan left a comment

Choose a reason for hiding this comment

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

Thank you for this PR which also tackles the long-standing #1026.

Comment on lines +82 to +89
void create_empty_target(
const Context& context,
const fs::u8path& prefix,
const std::map<std::string, std::string>& env_vars,
bool no_env
);
Copy link
Member

Choose a reason for hiding this comment

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

This will changes the API for mamba.

Must we do something specific (e.g. have default value for the new arguments) for it given that mamba has a specific policy for API and ABI stability?

Copy link
Member

@JohanMabille JohanMabille May 28, 2025

Choose a reason for hiding this comment

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

Answering to #3955 (comment):

Indeed, although this is in a detail namespace, this is visible in the ABI and this change is backward incompatible? We'ell have to update the ABI version accordingly (we can consider this change as API backward compatible since this method is not supposed to be used by clients).

On the long run, we should move all these detail functions in private headers (but this deserves a dedicated PR)

Comment on lines 433 to 435
file_content.append(
"variables: {'MY_ENV_VAR': 'My Value', 'MY_OTHER_ENV_VAR': 'Another Value'}",
)
Copy link
Member

Choose a reason for hiding this comment

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

Looking at this section from conda's documentation, it seems that is also a valid option which we must test:

variables:
  MY_ENV_VAR: 'My Value'
  MY_OTHER_ENV_VAR: 'Another Value'

Copy link
Member Author

Choose a reason for hiding this comment

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

Well it seems that we're using flow style everywhere in the tests when handling yaml files (I don't think the style changes anything functionally)...
But I changed to block style in b660b03 to have an example/reference.

Comment on lines +82 to +89
void create_empty_target(
const Context& context,
const fs::u8path& prefix,
const std::map<std::string, std::string>& env_vars,
bool no_env
);
Copy link
Member

@JohanMabille JohanMabille May 28, 2025

Choose a reason for hiding this comment

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

Answering to #3955 (comment):

Indeed, although this is in a detail namespace, this is visible in the ABI and this change is backward incompatible? We'ell have to update the ABI version accordingly (we can consider this change as API backward compatible since this method is not supposed to be used by clients).

On the long run, we should move all these detail functions in private headers (but this deserves a dedicated PR)

@pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True)
@pytest.mark.parametrize("env_vars", (False, True))
@pytest.mark.parametrize("no_env", (False, True))
def test_spec_file_env_vars(tmp_home, tmp_root_prefix, tmp_path, env_vars, no_env):
Copy link
Member

@jjerphan jjerphan May 28, 2025

Choose a reason for hiding this comment

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

I tested locally, and activating the environment successfully sets environment variables.

(I wonder whether there's a test checking that environment variables are set when the environment is activated. I am checking for it.)

@JohanMabille JohanMabille merged commit 5789fe4 into mamba-org:main May 28, 2025
60 of 63 checks passed
@Hind-M Hind-M deleted the std_yml_file branch May 28, 2025 12:17
SandrineP pushed a commit to SandrineP/mamba that referenced this pull request Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release::bug_fixes For PRs fixing bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not exactly following the standardized environment yaml file

3 participants