Merge pull request #6244 from Artturin/nixenvbettermessage

nix-env: Add a suggestion for when there's a name collision in channels
This commit is contained in:
Eelco Dolstra 2022-03-14 14:17:50 +01:00 committed by GitHub
commit a61809722f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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. */