diff --git a/src/main/java/com/google/devtools/build/lib/includescanning/SpawnIncludeScanner.java b/src/main/java/com/google/devtools/build/lib/includescanning/SpawnIncludeScanner.java index 06569c82ac7d77..fe6cfcc86ef2c1 100644 --- a/src/main/java/com/google/devtools/build/lib/includescanning/SpawnIncludeScanner.java +++ b/src/main/java/com/google/devtools/build/lib/includescanning/SpawnIncludeScanner.java @@ -283,8 +283,9 @@ public Collection extractInclusions( ActionExecutionContext actionExecutionContext, Artifact grepIncludes, GrepIncludesFileType fileType, - boolean placeNextToFile) + boolean isOutputFile) throws IOException, ExecException, InterruptedException { + boolean placeNextToFile = isOutputFile && !file.hasParent(); Path output = getIncludesOutput(file, actionExecutionContext.getPathResolver(), fileType, placeNextToFile); if (!inMemoryOutput) {