Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Don't modify reserved environment variables when (de)/activating#15342

Merged
jezdez merged 10 commits intoconda:mainfrom
soapy1:dont-change-path-var
Nov 4, 2025
Merged

Don't modify reserved environment variables when (de)/activating#15342
jezdez merged 10 commits intoconda:mainfrom
soapy1:dont-change-path-var

Conversation

@soapy1
Copy link
Contributor

@soapy1 soapy1 commented Oct 20, 2025

Description

Pt. 1 to address #15292

Users should not be able to change their PATH environment variable through their environment config.

This change will ignore these reserved variables (currently just PATH). And, will print a warning to the user if a reserved environment variable is detected.

For example, to test this out:

// create a new env
$ conda create -n myenv

// set the `PATH` variable for the env
$ conda env config vars set PATH="notsogood" -n myenv

// activate the environment - notice 
// 1. no error  - on the main branch of conda this will produce an error 
// 2. warning message
 $ conda activate myenv                               
WARNING: the configured environment variable(s) for prefix '/home/sophia/projects/conda/devenv/Linux/x86_64/envs/devenv-3.10-miniforge/envs/myenv' are reserved and will be ignored: PATH.

Remove the invalid configuration with `conda env config vars unset -p /home/sophia/projects/conda/devenv/Linux/x86_64/envs/devenv-3.10-miniforge/envs/myenv PATH`.


// deactivate the environment - notice
// 1. no error  - on the main branch of conda this will produce an error 
// 2. warning message
$ conda deactivate                             
WARNING: the configured environment variable(s) for prefix '/home/sophia/projects/conda/devenv/Linux/x86_64/envs/devenv-3.10-miniforge/envs/myenv' are reserved and will be ignored: PATH.

Remove the invalid configuration with `conda env config vars unset -p /home/sophia/projects/conda/devenv/Linux/x86_64/envs/devenv-3.10-miniforge/envs/myenv PATH`.


Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@github-project-automation github-project-automation bot moved this to 🆕 New in 🔎 Review Oct 20, 2025
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Oct 20, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 20, 2025

CodSpeed Performance Report

Merging #15342 will not alter performance

Comparing soapy1:dont-change-path-var (93ea5af) with main (9b57c59)1

Summary

✅ 23 untouched
⏩ 21 skipped2

Footnotes

  1. No successful run was found on main (3f3ee9b) during the generation of this report, so 9b57c59 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 21 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@soapy1
Copy link
Contributor Author

soapy1 commented Oct 20, 2025

pre-commit.ci autofix

@soapy1 soapy1 marked this pull request as ready for review October 21, 2025 04:33
@soapy1 soapy1 requested a review from a team as a code owner October 21, 2025 04:33
ryanskeith
ryanskeith previously approved these changes Oct 22, 2025
Copy link
Contributor

@ryanskeith ryanskeith left a comment

Choose a reason for hiding this comment

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

This looks good to me.

@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Approved in 🔎 Review Oct 22, 2025
@github-project-automation github-project-automation bot moved this from ✅ Approved to 🏗️ In Progress in 🔎 Review Oct 23, 2025
@soapy1
Copy link
Contributor Author

soapy1 commented Oct 23, 2025

pre-commit.ci autofix

Copy link
Contributor

@ryanskeith ryanskeith 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 as far as formatting. I think the warning clause needs to be out of the loop though before this is committed.

@soapy1 soapy1 force-pushed the dont-change-path-var branch from f4f34cb to d2a96b1 Compare October 23, 2025 22:33
@soapy1 soapy1 self-assigned this Oct 27, 2025
Copy link
Member

@jezdez jezdez left a comment

Choose a reason for hiding this comment

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

@soapy1 I took the liberty to push a change that I think improves this PR for vars that are unset with conda env config vars unset .. (yep, that's a real command!). If you're okay with my changes, I'd be happy to approve it, but we can work on it more if you'd like.

@jezdez
Copy link
Member

jezdez commented Oct 28, 2025

pre-commit.ci autofix

@soapy1
Copy link
Contributor Author

soapy1 commented Oct 28, 2025

One more change to add here. When I was testing this out and flipping beteween environments with valid and invalid configured env vars, it was confusing to know which environment the warning is coming from. Adding the prefix name to the warning to clarify this.

@soapy1
Copy link
Contributor Author

soapy1 commented Oct 28, 2025

One more change to add here. When I was testing this out and flipping beteween environments with valid and invalid configured env vars, it was confusing to know which environment the warning is coming from. Adding the prefix name to the warning to clarify this.

pushed this change. Now when a user activates/deactivates an environment with reserved environment variables configured, they get a warning like:

WARNING: the configured environment variable(s) for prefix '/tmp/vars' are reserved and will be ignored: PATH.

Remove the invalid configuration with `conda env config vars unset -p /tmp/vars PATH`.

soapy1 and others added 5 commits October 28, 2025 10:34
For example, users should not be able to change their PATH
environment variable thru their environment config.

This change will ignore these reserved variables and print
a warning to the user.
@soapy1
Copy link
Contributor Author

soapy1 commented Nov 3, 2025

If you're okay with my changes, I'd be happy to approve it, but we can work on it more if you'd like.

@jezdez I'm good with these changes. Do you want to give it a once thru before merging?

@github-project-automation github-project-automation bot moved this from 🏗️ In Progress to ✅ Approved in 🔎 Review Nov 4, 2025
@jezdez jezdez merged commit 3ba3d38 into conda:main Nov 4, 2025
76 checks passed
@github-project-automation github-project-automation bot moved this from ✅ Approved to 🏁 Done in 🔎 Review Nov 4, 2025
@github-project-automation github-project-automation bot moved this from In review 🔍 to Done 💪🏾 in conda Roadmap and Sprint Planning Nov 4, 2025
@soapy1 soapy1 deleted the dont-change-path-var branch November 4, 2025 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed [bot] added once the contributor has signed the CLA

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants