-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix behavior of --no-user flag in conda init
#11949
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
Conversation
It is clear from the code that `args.no_user` should have a value of `True` when the `--no-user` flag is provided, so that the user's `.bashrc`, etc. is not updated.
|
We require contributors to sign our Contributor License Agreement and we don't have one on file for @xylar. In order for us to review and merge your code, please e-sign the Contributor License Agreement PDF. We then need to manually verify your signature. We will ping the bot to refresh the PR status when we have confirmed your signature. |
fc13e85 to
3218283
Compare
|
Needs a test. |
|
@dholth, I would be happy to add a test but I would need some hand-holding as this is my first time attempting to contribute to |
|
We will probably be able to merge this. The argument is processed here in https://github.com/conda/conda/blob/main/conda/cli/main_init.py#L34 . There are enough negatives that it takes a while to convince ourselves that the new code is correct. It looks like the flag never worked properly. for_user = args.user
if not (args.install and args.user and args.system):
for_user = True
if args.no_user:
for_user = False |
Yes, I belief that's the case. I did test this locally and it worked as expected. (In the meantime, I'm working around this by just moving my |
|
Did you figure out why there is an args.user and and args.no_user |
|
I don't believe there is a difference between having |
|
Sorry for all the back and forth; related commits |
|
Here's what it "should" look like and in main_init, |
This is more intuitive to follow through the code but has the complication that the default mush be handled differently.
Okay, I'm willing to give this |
|
Thanks! We'll get this done carefully. |
|
Also, happy to squash my commits to keep things cleaner, I just don't want to cause any undue confusion. |
|
Okay, I couldn't let this go and I did some more testing. The logic works up to this line: Lines 32 to 33 in e3bbd92
But then we have: It seems that currently the only way to prevent my I can't imagine this is the intended behavior. |
|
Looking back at the commit history, I think: Lines 32 to 33 in e3bbd92
used to make sense when --no-user didn't exist and --user was not the default (it had to be specified). Even then, I think the logic was probably wrong. I think it was probably meant to say, if none of --user, --install and --system is provided, do a user init. But it actually said if all 3 flags are not provided, do a user init. This is odd because --user and --system don't seem to make sense at the same time.
My sense at this point is that this line just doesn't make sense anymore at all and should be removed. I'm going to do that (and include this long explanation). |
Looking back at the commit history, I think:
```
if not (args.install and args.user and args.system):
for_user = True
```
used to make sense when `--no-user` didn't exist and `--user` was
not the default (it had to be specified). Even then, I think the
logic was probably wrong. I think it was probably meant to say,
if none of `--user`, `--install` and `--system` is provided, do a
user init. But it actually said if all 3 flags are not provided,
do a user init. This is odd because `--user` and `--system`
don't seem to make sense at the same time.
My sense at this point is that this line just doesn't make sense
anymore at all and should be removed.
|
With my latest change, I have verified that but that |
|
@dholth, please give this another look when you have time. |
|
https://docs.conda.io/projects/conda/en/latest/commands/init.html?highlight=Conda%20init It makes intuitive sense that --system could disable --user. We just have to replace the old logic. |
Just saw this comment
Okay, I agree. Let's make this work the way it's supposed to! |
|
So if someone specifies both And what is |
|
@dholth, just wondering about the process here. Is there anything more I need to do to see this get merged at some point? |
|
Thanks, I've tagged this appropriately. We will merge it within a couple of weeks +- holidays |
dholth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much!
|
Updated to fix the See: https://github.com/conda/conda/actions/runs/3414753536/jobs/6144233243#step:7:709 |
|
🤞🏻 |
This merge makes changes similar to conda/conda#11949 to fix `mamba init` so that the `--no-user` flag actually has the intended effect of not changing a user's `.bashrc` or equivalent. Without this change, `--no-user` has no effect as was previously the case in conda, see: conda/conda#11948
* Fix `mamba init --no-user` This merge makes changes similar to conda/conda#11949 to fix `mamba init` so that the `--no-user` flag actually has the intended effect of not changing a user's `.bashrc` or equivalent. Without this change, `--no-user` has no effect as was previously the case in conda, see: conda/conda#11948 * Fix for conda < 23.1.0 * Revert back to old code when `args.no_user` present This is still broken with the `--no-user`, as noted, but at least newer versions of conda (>=23.1.0) will work as expected.
Description
Before this merge, calls to
do not have the desired effect of not modifying the user's
.bashrc, etc.See #11948.
This merge fixes that by making sure
args.useris now set toFalsewhen the--no-userflag is provided, ultimately resulting in no attempt to modify the.bashrcor equivalent.Checklist - did you ...
newsdirectory (using the template) for the next release's release notes?closes #11948
closes #9739