Skip to content

Commit

Permalink
Improve error message for unresolved toolchains
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsauer authored Mar 29, 2022
1 parent 13ae2c6 commit bda8424
Showing 1 changed file with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Pattern;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -570,20 +571,13 @@ protected Code getDetailedCode() {
}

private static String getMessage(List<Label> missingToolchainTypes) {
if (missingToolchainTypes.size() == 1
&& Iterables.getOnlyElement(missingToolchainTypes)
.toString()
.equals("@bazel_tools//tools/cpp:toolchain_type")) {
return "No matching toolchains found for types @bazel_tools//tools/cpp:toolchain_type. "
+ "Maybe --incompatible_use_cc_configure_from_rules_cc has been flipped and there "
+ "is no default C++ toolchain added in the WORKSPACE file? See "
+ "https://github.com/bazelbuild/bazel/issues/10134 for details and migration "
+ "instructions.";
}

List<String> labelStrings =
missingToolchainTypes.stream().map(Label::toString).collect(Collectors.toList());
return String.format(
"no matching toolchains found for types %s",
missingToolchainTypes.stream().map(Label::toString).collect(joining(", ")));
"No matching toolchains found for types %s. "
+ "To debug, rerun with --toolchain_resolution_debug=%s",
String.join(", ", labelStrings),
labelStrings.stream().map(Pattern::quote).collect(joining("|")));
}
}

Expand Down

0 comments on commit bda8424

Please sign in to comment.