Skip to content

Add support for conda init --condabin, which adds condabin/ to PATH #965

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

Open
wants to merge 137 commits into
base: main
Choose a base branch
from

Conversation

jaimergp
Copy link
Contributor

@jaimergp jaimergp commented Mar 24, 2025

Description

Closes #960.

Based on #943 to avoid conflicts down the line because this adds new options to construct.yaml. Excuse the diff while 943 gets reviewed.

Windows:

image

macOS:

image

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?

@@ -675,9 +694,66 @@ if [ "${PYTHONPATH:-}" != "" ]; then
printf " directories of packages that are compatible with the Python interpreter\\n"
printf " in %s: %s\\n" "${INSTALLER_NAME}" "$PREFIX"
fi
{% if has_conda %}
{%- if initialize_conda == 'condabin'%}
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
{%- if initialize_conda == 'condabin'%}
{%- if initialize_conda == 'condabin' %}

input_path = _example_path("condabin")
for installer, install_dir in create_installer(input_path, tmp_path):
if installer.suffix == ".exe":
options = ["/AddToPath=1"]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the test is failing on Windows because you're admin on GitHub runner.

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'm afraid that's true. I'm looking at options to run as a different user but they are really hacky.

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 tried my best as you can see in all the commits underneath, but there seems to be a permissions issue to run pytest from the non-admin account. That said, I checked on the VM and:

  1. The test doesnt' pass there either
  2. BUT the PATH environment var modification can be seen in the Control Panel dialog.
  3. The assertion does pass in a new terminal window

I tried several ways to start a fresh process (subprocess flags, os.startfile...), and no luck.

I did check locally that the PATH is indeed modified, so it works, but it can't be tested on CI :/

Copy link
Contributor

@marcoesters marcoesters Jun 25, 2025

Choose a reason for hiding this comment

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

So, it looks like you essentially have to restart your shell and environment variables do not propagate into the child processes pytest starts. Does checking the registry work on your local system?

If so, I have the following suggestion that actually checks two things at once:

  • Check if user is an admin via ctypes.windll.shell32.IsUserAnAdmin()
  • Force the installation to use /InstallationType=JustMe.
  • If the user is an admin, mark the test as xfail. This will also check whether the CVE that disables adding to path with an admin installation has been re-introduced.
  • Parametrize the test to check for both classic and condabin - I don't think there is a test for that yet.

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
Status: 🆕 New
Development

Successfully merging this pull request may close these issues.

Support adding condabin/ to PATH
4 participants