Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable user site-packages during de[activation] #12438

Closed

Conversation

jjhelmus
Copy link
Contributor

@jjhelmus jjhelmus commented Mar 3, 2023

Description

Disable the user site-packages directory when retrieving the shell code for activation, deactivation and reactivation from CONDA_EXE. The output from these calls are evaluated by the shell and any extraneous output introduced by the user site-packages directory, such as by usercustomize.py or .pth files, will be evaluated.

An alternative would be to use Python in isolated mode (-I) to run the CONDA_EXE script. This would also ignore the PYTHON* environment variables and unsafe paths.

Note that this only adds this to Unix style shells. Windows specific shells (cmd, powershell) may still access the user site-packages directory during activation.

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?

closes #12444

@jjhelmus jjhelmus requested a review from a team as a code owner March 3, 2023 21:46
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Mar 3, 2023
@jezdez
Copy link
Member

jezdez commented Mar 6, 2023

@jjhelmus Would you mind opening an issue please? We're trying to get away from PRs without prior record-keeping of what is being solved.

@jjhelmus
Copy link
Contributor Author

jjhelmus commented Mar 6, 2023

@jjhelmus Would you mind opening an issue please? We're trying to get away from PRs without prior record-keeping of what is being solved.

Reported the issue in #12444

@jjhelmus
Copy link
Contributor Author

jjhelmus commented Mar 6, 2023

The failing test is a result of conda being re-installed from defaults during the setup in the associated job:

The following packages will be SUPERSEDED by a higher-priority channel:

  anaconda-client    conda-forge/noarch::anaconda-client-1~ --> pkgs/main/linux-64::anaconda-client-1.11.0-py310h06a4308_0 
  beautifulsoup4     conda-forge/noarch::beautifulsoup4-4.~ --> pkgs/main/linux-64::beautifulsoup4-4.11.1-py310h06a4308_0 
  certifi            conda-forge/noarch::certifi-2022.12.7~ --> pkgs/main/linux-64::certifi-2022.12.7-py310h06a4308_0 
  chardet            conda-forge::chardet-5.1.0-py310hff52~ --> pkgs/main::chardet-4.0.0-py310h06a4308_1003 
  conda              conda-forge::conda-23.1.0-py310hff520~ --> pkgs/main::conda-23.1.0-py310h06a4308_0

This occurs in all the Linux conda-forge jobs.

Essentially these jobs are testing if the tests in this repo pass with the latest defaults conda package.

This test behavior should be fixed so that the development version of conda is tested with conda-forge packages but is outside the scope of this PR.

@jezdez
Copy link
Member

jezdez commented Mar 6, 2023

BTW curious that chardet is older in main :-/

@travishathaway
Copy link
Contributor

travishathaway commented May 4, 2023

@jezdez, are we still trying to get this in for the upcoming release? The tests look like they are passing (there's just a single random error).

@jezdez
Copy link
Member

jezdez commented May 4, 2023

@jezdez, are we still trying to get this in for the upcoming release? The tests look like they are passing (there's just a single random error).

Yeah, I think so, even though I'm not excited that this doesn't fix the Windows activation :-/

Disable the user site-packages directory when retriving the shell code
for activation, deactivation and reactivation from CONDA_EXE. The output
from these calls are evaluated by the shell and any extraneous output
introduced by the user site-packages directory, such as by usercustomize.py
or .pth files, will be evaluated.

An alternative would be to use Python in isolated mode (-I) to run the
CONDA_EXE script. This would also ignore the PYTHON* environment
variables and unsafe paths.
@jezdez jezdez force-pushed the disable_usersite_during_activation branch from 6ed0ee4 to 123c00f Compare June 6, 2023 08:50
@jezdez
Copy link
Member

jezdez commented Jun 6, 2023

pre-commit.ci autofix

@jezdez jezdez changed the title disable user site-packages during de[activation] Disable user site-packages during de[activation] Jun 6, 2023
@jezdez jezdez enabled auto-merge (squash) June 6, 2023 11:12
Copy link
Contributor

@kenodegard kenodegard left a comment

Choose a reason for hiding this comment

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

the test as written passes on Windows without these changes so thats a false positive that should be removed

Copy link

Hi there, thank you for your contribution!

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further activity occurs.

If you would like this pull request to remain open please:

  1. Rebase and verify the changes still work
  2. Leave a comment with the current status

NOTE: If this pull request was closed prematurely, please leave a comment.

Thanks!

@github-actions github-actions bot added the stale [bot] marked as stale due to inactivity label Sep 22, 2024
@github-actions github-actions bot added the stale::closed [bot] closed after being marked as stale label Oct 22, 2024
@github-actions github-actions bot closed this Oct 22, 2024
@github-actions github-actions bot closed this Oct 22, 2024
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 stale::closed [bot] closed after being marked as stale stale [bot] marked as stale due to inactivity
Projects
Status: 🏁 Done
Development

Successfully merging this pull request may close these issues.

Arbitrary code can be run at conda activate/deactivate by modules in user site-packages directory
5 participants