Skip to content

Commit

Permalink
Fix mamba init --no-user (#2324)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
xylar authored Feb 26, 2023
1 parent f279b48 commit 4138630
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions mamba/mamba/mamba_shell_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,18 @@ def shell_init(args):
return initialize_dev(shell)

else:
for_user = args.user
if not (args.install and args.user and args.system):
for_user = True
# no_user removed in Conda 23.1.0, see https://github.com/mamba-org/mamba/issues/2248
if hasattr(args, "no_user") and args.no_user:
for_user = False
if hasattr(args, "no_user"):
# this seems to be conda < 23.1.0
# Here, we use the old behavior even though the --no-user flag
# doesn't behave as desired, see:
# https://github.com/conda/conda/issues/11948
for_user = args.user
if not (args.install and args.user and args.system):
for_user = True
if args.no_user:
for_user = False
else:
for_user = args.user and not args.system

anaconda_prompt = on_win and args.anaconda_prompt
exit_code = initialize(
Expand Down

0 comments on commit 4138630

Please sign in to comment.