diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/RepoFileFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/RepoFileFunction.java index cbafb02610079a..e41f2eae14db28 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/RepoFileFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/RepoFileFunction.java @@ -75,6 +75,10 @@ public SkyValue compute(SkyKey skyKey, Environment env) if (repoDirValue == null) { return null; } + if (!repoDirValue.repositoryExists()) { + throw new RepoFileFunctionException( + new IOException(repoDirValue.getErrorMsg()), Transience.PERSISTENT); + } repoRoot = repoDirValue.getPath(); } RootedPath repoFilePath = diff --git a/src/test/shell/bazel/workspace_test.sh b/src/test/shell/bazel/workspace_test.sh index 220797c069106e..8d27e8847831d5 100755 --- a/src/test/shell/bazel/workspace_test.sh +++ b/src/test/shell/bazel/workspace_test.sh @@ -66,6 +66,10 @@ EOF assert_contains "bye" bazel-genfiles/external/x/out } +function test_build_non_existing_repo() { + bazel build @blah &>$TEST_log && fail "Failure expected" || true + expect_log "Repository '@@blah' is not defined" +} function test_path_with_spaces() { ws="a b"