Skip to content

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jul 17, 2025

Fix nix help shell by properly handling command aliases

Closes: #13431

Problem

The nix help shell command incorrectly fails with Nix has no subcommand 'shell' despite nix shell --help working correctly. This happens because shell is actually an alias for env shell, and the help system wasn't resolving these aliases when looking up documentation.

This creates a confusing user experience where the shell command both exists and doesn't exist depending on how users try to access its documentation.

Solution

This PR modifies the showHelp function in src/nix/main.cc to check for and resolve aliases before generating the manpage name. When a user requests help for an aliased command like shell, the system now correctly looks up the documentation for the actual command (env shell).

The implementation is straightforward - it adds a few lines to the showHelp function to check if the requested subcommand matches any aliases in the toplevel.aliases map, and if so, replaces the subcommand with the actual command path before generating the manpage name.


This is an automatic backport of pull request #13496 done by Mergify.

Previously, `nix help shell` failed with "Nix has no subcommand 'shell'" despite `nix shell --help`
working correctly. This happened because the `shell` command is actually an alias for `env shell`,
and the help system wasn't resolving aliases when looking up documentation.

This patch modifies the `showHelp` function to check for and resolve aliases before generating the
manpage name, ensuring that shorthand commands like `shell` get proper help documentation.

Closes: #13431
(cherry picked from commit d678b07)
@mergify mergify bot added automatic backport This PR is a backport produced by automation (does not trigger backporting) merge-queue labels Jul 17, 2025
@mergify mergify bot requested a review from edolstra as a code owner July 17, 2025 17:42
@mergify mergify bot added merge-queue automatic backport This PR is a backport produced by automation (does not trigger backporting) labels Jul 17, 2025
@github-actions github-actions bot added the new-cli Relating to the "nix" command label Jul 17, 2025
@mergify mergify bot merged commit 65f4357 into 2.28-maintenance Jul 17, 2025
27 checks passed
@mergify mergify bot deleted the mergify/bp/2.28-maintenance/pr-13496 branch July 17, 2025 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automatic backport This PR is a backport produced by automation (does not trigger backporting) merge-queue new-cli Relating to the "nix" command
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant