From 9fa69276c4e72916afe9de136f05d6d6e47fb7bb Mon Sep 17 00:00:00 2001 From: Jens Petersen Date: Thu, 22 Jan 2026 12:31:46 +0800 Subject: [PATCH] nix config check: improve error when no nix-env It is possible that the `nix` executable is installed but not `nix-env` (this may be unusual but for example in Fedora we have a separate `nix-legacy` subpackage, which includes the `nix-env` symlink). The current error message: ``` $ nix config check --verbose Running checks against store uri: local [FAIL] Multiple versions of nix found in PATH: ``` when there is no nix-env in PATH is confusing. This change makes the error message precise for the missing nix-env case. --- src/nix/config-check.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/nix/config-check.cc b/src/nix/config-check.cc index e1efb40eb..999d916f7 100644 --- a/src/nix/config-check.cc +++ b/src/nix/config-check.cc @@ -95,7 +95,9 @@ struct CmdConfigCheck : StoreCommand dirs.insert(std::filesystem::canonical(candidate).parent_path()); } - if (dirs.size() != 1) { + if (dirs.empty()) { + return checkFail("No nix-env found in PATH."); + } else if (dirs.size() > 1) { std::ostringstream ss; ss << "Multiple versions of nix found in PATH:\n"; for (auto & dir : dirs)