From cb1a76112eb77883038ebad8d3b0e39330bdf1b3 Mon Sep 17 00:00:00 2001 From: Artturin Date: Sat, 12 Mar 2022 23:58:29 +0200 Subject: [PATCH] nix-env: Add a suggestion for when there's a name collision in channels help new users find a solution to their problem ./result/bin/nix-env -qa hello warning: name collision in input Nix expressions, skipping '/home/artturin/.nix-defexpr/channels_root/master' suggestion: remove 'master' from either the root channels or the user channels hello-2.12 hello-2.12 --- src/nix-env/nix-env.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index 40c3c5d65..eb5fbc08f 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -128,7 +128,12 @@ static void getAllExprs(EvalState & state, if (hasSuffix(attrName, ".nix")) attrName = std::string(attrName, 0, attrName.size() - 4); if (!seen.insert(attrName).second) { - printError("warning: name collision in input Nix expressions, skipping '%1%'", path2); + std::string suggestionMessage = ""; + if (path2.find("channels") != std::string::npos && path.find("channels") != std::string::npos) { + suggestionMessage = fmt("\nsuggestion: remove '%s' from either the root channels or the user channels", attrName); + } + printError("warning: name collision in input Nix expressions, skipping '%1%'" + "%2%", path2, suggestionMessage); continue; } /* Load the expression on demand. */