From 6ef00a503a62dc5554139804d22968b25ba4bf3f Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Fri, 5 Jul 2024 18:32:34 +0200 Subject: [PATCH] Explain when man is missing Have you seen this man? Fixes #10677 --- src/libmain/shared.cc | 4 ++++ tests/functional/misc.sh | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index c1c936248..fc55fe3f1 100644 --- a/src/libmain/shared.cc +++ b/src/libmain/shared.cc @@ -320,6 +320,10 @@ void showManPage(const std::string & name) restoreProcessContext(); setEnv("MANPATH", settings.nixManDir.c_str()); execlp("man", "man", name.c_str(), nullptr); + if (errno == ENOENT) { + // Not SysError because we don't want to suffix the errno, aka No such file or directory. + throw Error("The '%1%' command was not found, but it is needed for '%2%' and some other '%3%' commands' help text. Perhaps you could install the '%1%' command?", "man", name.c_str(), "nix-*"); + } throw SysError("command 'man %1%' failed", name.c_str()); } diff --git a/tests/functional/misc.sh b/tests/functional/misc.sh index 9eb80ad22..7d63756b7 100755 --- a/tests/functional/misc.sh +++ b/tests/functional/misc.sh @@ -13,6 +13,9 @@ source common.sh # Can we ask for the version number? nix-env --version | grep "$version" +nix_env=$(type -P nix-env) +(PATH=""; ! $nix_env --help 2>&1 ) | grepQuiet -F "The 'man' command was not found, but it is needed for 'nix-env' and some other 'nix-*' commands' help text. Perhaps you could install the 'man' command?" + # Usage errors. expect 1 nix-env --foo 2>&1 | grep "no operation" expect 1 nix-env -q --foo 2>&1 | grep "unknown flag"