Skip to content

fix: Remove duplicate deactivate from shell completion - #4371

Merged
jjerphan merged 2 commits into
mamba-org:mainfrom
henriquesimoes:completion
Aug 6, 2026
Merged

fix: Remove duplicate deactivate from shell completion#4371
jjerphan merged 2 commits into
mamba-org:mainfrom
henriquesimoes:completion

Conversation

@henriquesimoes

Copy link
Copy Markdown
Contributor

Description

When implementing the shell completion, the "deactivate" command is introduced manually in add_activate_completion(). When first introduced by 821de6b (also complete for deactivate command (#1557), 2022-03-03) this was needed (although probably in the wrong function), because micromamba didn't have a proper "deactivate" command.

However, commit 5206c2a (fix: Add deactivate command to the help message (#4350), 2026-07-29) added this missing command to set_umamba_command() (that is also used for handling the "completer" command), but it didn't remove the extra "deactivate". Because of that, running the autocompletion triggers the following error:

terminate called after throwing an instance of 'CLI::OptionAlreadyAdded'
what():  subcommand name or alias matches existing subcommand: deactivate is already added

Drop the manual and redundant addition of "deactivate" command in the completer implementation, so the autocompletion gets back to working as expected.

Fixes: 5206c2a (fix: Add deactivate command to the help message (#4350), 2026-07-29)

Type of Change

  • Bugfix
  • Feature / enhancement
  • CI / Documentation
  • Maintenance

Checklist

  • My code follows the general style and conventions of the codebase, ensuring consistency
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have run pre-commit run --all locally in the source folder and confirmed that there are no linter errors.
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes

When implementing the shell completion, the "deactivate" command is
introduced manually in add_activate_completion(). When first introduced
by 821de6b (also complete for deactivate command (mamba-org#1557), 2022-03-03)
this was needed (although probably in the wrong function), because
micromamba didn't have a proper "deactivate" command.

However, commit 5206c2a (fix: Add `deactivate` command to the help
message (mamba-org#4350), 2026-07-29) added this missing command to
set_umamba_command() (that is also used for handling the "completer"
command), but it didn't remove the extra "deactivate". Because of that,
running the autocompletion triggers the following error:

    terminate called after throwing an instance of 'CLI::OptionAlreadyAdded'
    what():  subcommand name or alias matches existing subcommand: deactivate is already added

Drop the manual and redundant addition of "deactivate" command in the
completer implementation, so the autocompletion gets back to working as
expected.

Fixes: 5206c2a (fix: Add `deactivate` command to the help message (mamba-org#4350), 2026-07-29)
Signed-off-by: Henrique F. Simoes <henrique.simoes@lnls.br>
@github-actions github-actions Bot added the release::bug_fixes For PRs fixing bugs label Aug 4, 2026
@jjerphan jjerphan changed the title micromamba: remove duplicate deactivate from shell completion fix: Remove duplicate deactivate from shell completion Aug 6, 2026

@jjerphan jjerphan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch! I can reproduce it.

Exercise top-level, prefix, env-name, shell, and option completion so a
duplicate deactivate subcommand (CLI::OptionAlreadyAdded) cannot regress.
@jjerphan
jjerphan merged commit af65e50 into mamba-org:main Aug 6, 2026
33 of 34 checks passed
@henriquesimoes

Copy link
Copy Markdown
Contributor Author

@jjerphan, thanks for the review and for adding the missing test to avoid future regressions. ;)

@jjerphan

jjerphan commented Aug 7, 2026

Copy link
Copy Markdown
Member

Thank you for this fix, @henriquesimoes.

We have been lucky to include it as part of 2.9.0. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release::bug_fixes For PRs fixing bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants