diff --git a/src/main/java/com/google/devtools/build/lib/remote/AbstractActionInputPrefetcher.java b/src/main/java/com/google/devtools/build/lib/remote/AbstractActionInputPrefetcher.java index a037811a8e70e2..a87e170ecf8b2f 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/AbstractActionInputPrefetcher.java +++ b/src/main/java/com/google/devtools/build/lib/remote/AbstractActionInputPrefetcher.java @@ -490,7 +490,7 @@ private Completable downloadFileNoCheckRx( Priority priority) { if (path.isSymbolicLink()) { try { - path = path.getRelative(path.readSymbolicLink()); + path = path.resolveSymbolicLinks(); } catch (IOException e) { return Completable.error(e); } diff --git a/src/test/java/com/google/devtools/build/lib/remote/BuildWithoutTheBytesIntegrationTestBase.java b/src/test/java/com/google/devtools/build/lib/remote/BuildWithoutTheBytesIntegrationTestBase.java index 02529d8c9de2dc..b487d214e108b9 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/BuildWithoutTheBytesIntegrationTestBase.java +++ b/src/test/java/com/google/devtools/build/lib/remote/BuildWithoutTheBytesIntegrationTestBase.java @@ -885,6 +885,36 @@ public void remoteCacheEvictBlobs_whenPrefetchingInputTree_incrementalBuildCanCo /* isLocal= */ true); } + @Test + public void nonDeclaredSymlinksFromLocalActions() throws Exception { + write( + "BUILD", + "genrule(", + " name = 'foo',", + " srcs = [],", + " outs = ['foo.txt'],", + " cmd = 'echo foo > $@',", + ")", + "genrule(", + " name = 'foo-link',", + " srcs = [':foo'],", + " outs = ['foo.link'],", + " cmd = 'ln -s foo.txt $@',", + " local = True,", + ")", + "genrule(", + " name = 'foobar',", + " srcs = [':foo-link'],", + " outs = ['foobar.txt'],", + " cmd = 'cat $(location :foo-link) > $@ && echo bar >> $@',", + " local = True,", + ")"); + + buildTarget("//:foobar"); + + assertValidOutputFile("foobar.txt", "foo\nbar\n"); + } + protected void assertOutputsDoNotExist(String target) throws Exception { for (Artifact output : getArtifacts(target)) { assertWithMessage(