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 97 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?

@jaimergp jaimergp changed the title (WIP) Add option to add condabin/ to PATH Add support for conda init --condabin, which adds condabin/ to PATH Jun 16, 2025
@jaimergp jaimergp marked this pull request as ready for review June 16, 2025 10:50
@jaimergp jaimergp requested a review from a team as a code owner June 16, 2025 10:50
@jaimergp
Copy link
Contributor Author

@marcoesters, I think this is ready! It'd be nice to check if it behaves as intended locally too. Maybe I can extend the tests to actually check for PATH values but we are already testing that in the conda test suite 🤷

Also, I'd like to hear what you think about the proposed UI/text changes. I'd be happy to change whatever there, not feeling particularly strongly, but I do want to make it less confusing for end users.

@marcoesters
Copy link
Contributor

@marcoesters, I think this is ready! It'd be nice to check if it behaves as intended locally too. Maybe I can extend the tests to actually check for PATH values but we are already testing that in the conda test suite 🤷

It would still be good to test that the installers implement this correctly.

Also, I'd like to hear what you think about the proposed UI/text changes. I'd be happy to change whatever there, not feeling particularly strongly, but I do want to make it less confusing for end users.

On Windows, I'm not sure it's obvious what the benefit of one option over the other is, so having both available is not a great idea. So, I propose to either have installer providers a) choose what they want /AddToPath to add to the path ($INSTDIR or condabin), or b) to allow /AddToPath to be disabled. If we choose a), we also need to decide on what the default value should be.

Copy link
Contributor

@soapy1 soapy1 left a comment

Choose a reason for hiding this comment

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

Looks great! Just a couple of questions

### `add_condabin_to_path_default`

Default value for the option added by `add_condabin_to_path`. The default
is true for GUI installers (EXE, PKG) and false for shell installers. The user
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the motivation behind making this default value different for different types of installers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Consistency with previous UX. I assume the notion is that GUI users don't want to mess too much with the terminal, while shell installer users would be more ok with some tinkering. It's a bad proxy though.

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 consistency with previous UX is to not make it the default because in past UX, that option did not exist. If I updated constructor without making changes to the construct.yaml file, my installer would behave differently.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

An installer built with an updated constructor wouldn't see any changes in behaviour because add_condabin_to_path defaults to false. This is the default value once add_condabin_to_path is true.

@jaimergp
Copy link
Contributor Author

jaimergp commented Jun 17, 2025

On Windows, I'm not sure it's obvious what the benefit of one option over the other is, so having both available is not a great idea.

It's on the installer creator to offer both. By default, the condabin option is disabled. The installer creator has to opt-in. I would assume that at that point they will know what to do about the classic initialization option (disable it). I tried to discuss this in the docs.

a) choose what they want /AddToPath to add to the path ($INSTDIR or condabin)

They have two flags, which can be used together if needed, but it's on the installer creator to actually provide them.

b) to allow /AddToPath to be disabled

This will need a different PR, and it actually opened a can of worms. I'll open an issue to discuss it and then a potential fix.

@jaimergp
Copy link
Contributor Author

Comment on lines +127 to +133
{%- if add_condabin_to_path %}
{%- if add_condabin_to_path_default %}
-z do not add PREFIX/condabin to PATH; ignored in interactive mode
{%- else %}
-c add PREFIX/condabin to PATH; ignored in interactive mode
{%- endif %}
{%- endif %}
Copy link
Contributor

Choose a reason for hiding this comment

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

I am concerned about adding these additional, complementary flags here. #982 already tried to implement an extra flag for another option. If we add #1004 to the mix, I am concerned about maintainability.

The order of the flags is also getting a little chaotic. I wonder if we should keep the existing behavior of adding to path and initializing should be off in non-interactive mode unless opted in.

Copy link
Contributor Author

@jaimergp jaimergp Jun 18, 2025

Choose a reason for hiding this comment

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

We still need the flags to opt-in so which ones do you recommend? We can also make it a single flag option like -c OPTION Whether to initialize conda in some way: shell, condabin, none. This would make initialize_conda and add_condabin_to_path mutually exclusive though. Do you think we should turn initialize_conda into an enum type instead of a bool directly?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we need flags to opt in. My concern is more to have two different flags for the opt-in/opt-out behavior. It would be ideal if we used long options, which are more explicit than -c. What do you think?

Comment on lines +226 to +228
inject some shell functions so you can run `conda` from anywhere. That is, the `conda` executable
you usually run is not the Python entry point, but a shell function that ends up calling that entry
point. This wrapper is needed by `conda (de)activate` to operate correctly, since it needs to
Copy link
Contributor

Choose a reason for hiding this comment

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

The sentence starting with "That is, ..." was a little confusing for me to read. Is it needed at all?

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 think it's an important distinction to make, but happy to hear alternative wordings to make it clearer.

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
inject some shell functions so you can run `conda` from anywhere. That is, the `conda` executable
you usually run is not the Python entry point, but a shell function that ends up calling that entry
point. This wrapper is needed by `conda (de)activate` to operate correctly, since it needs to
inject some shell functions so you can run `conda` from anywhere. That is, the `conda` "executable"
you usually run is not the `conda` entry point, but a shell function that ends up calling the actual entry
point. This wrapper is needed by `conda (de)activate` to operate correctly, since it needs to

I think the "Python entry point", while technically correct, is coming a little out of nowhere. Maybe this?

### `add_condabin_to_path_default`

Default value for the option added by `add_condabin_to_path`. The default
is true for GUI installers (EXE, PKG) and false for shell installers. The user
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 consistency with previous UX is to not make it the default because in past UX, that option did not exist. If I updated constructor without making changes to the construct.yaml file, my installer would behave differently.

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