Misleading error message from `nix-env`

❯ nix-env
error: no operation specified
Try 'nix-env --help' for more information.

~
❯ nix-env --help
Unknown locale, assuming C
No manual entry for nix-env

Both errors seem descriptive enough, what’s the issue? If you don’t have the manpages for nix for some reason, then nix-env --help will fail.

I guess you are running 2.26.1? In that case the issue is likely Man pages are not installed with Nix 2.26.1 · Issue #12382 · NixOS/nix · GitHub.
This should be mostly fixed in 2.26.3 and up.

1 Like

The first message makes a promise that it can’t fullfill.

If the help message actually depends on a man page (that’s not how things usually work with other CLI tools), then it shoudl recommend typing “man nix-env” instead of “nix-env --help” which is expected to be self-contained.

nix is meant to be installed with its man pages, if that’s not done then the nix installation is broken, that’s a totally separate issue from the error message.

That’s not the issue I’m raising here.

Send a PR if you feel strongly about it.

It is reasonably common for --help to just defer to a man page or something. It’s probably not as common as --help having its own independent output, but it’s common enough. git does it this way, for instance.

1 Like

It does indeed, for git help git (the extensive version), but not for git --help (the concise version).

Indeed it doesn’t do it for the top level git command. Try it for any subcommand. git log --help. The subcommands all use the man page for their --help.

FWIW, the nix3 CLI also doesn’t appear rely on man? It just spits out the contents of the manpage directly into the terminal (for example, see nix shell --help). Wonder why it’s different from the nix2 CLI.

It does appear to still use a pager like less, but yea it doesn’t just invoke man.

Not on my system; nix2 (via man) of course respects PAGER but nix3 doesn’t appear to.

Huh, weird. On my system nix shell --help goes through the pager.