When I use Bazel 0.15.2 to rebuild Bazel I got this error sometimes:
ERROR: C:/tools/msys64/home/pcloudy/workspace/bazel/src/main/java/com/google/devtools/build/skyframe/BUILD:25:1: Building src/main/java/com/google/devtools/build/skyframe/libskyframe.jar (72 source files) and running annotation processors (AutoCodecProcessor, OptionProcessor) failed (Exit 1): java.exe failed: error executing command
cd C:/users/pcloudy/_bazel_pcloudy/3uxo2r6v/execroot/io_bazel
SET LC_CTYPE=en_US.UTF-8
external/embedded_jdk/bin/java.exe -Xbootclasspath/p:external/bazel_tools/third_party/java/jdk/langtools/javac-9+181-r4173-1.jar -jar external/bazel_tools/tools/jdk/JavaBuilder_deploy.jar @bazel-out/x64_windows-fastbuild/bin/src/main/java/com/google/devtools/build/skyframe/libskyframe.jar-2.params
java.io.IOException: Cannot clean 'bazel-out\x64_windows-fastbuild\bin\src\main\java\com\google\devtools\build\skyframe\_javac\skyframe\libskyframe_classes'
at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.cleanupDirectory(SimpleJavaLibraryBuilder.java:91)
at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.prepareSourceCompilation(SimpleJavaLibraryBuilder.java:53)
at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.compileJavaLibrary(SimpleJavaLibraryBuilder.java:113)
at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.run(SimpleJavaLibraryBuilder.java:132)
at com.google.devtools.build.buildjar.BazelJavaBuilder.processRequest(BazelJavaBuilder.java:105)
at com.google.devtools.build.buildjar.BazelJavaBuilder.runPersistentWorker(BazelJavaBuilder.java:67)
at com.google.devtools.build.buildjar.BazelJavaBuilder.main(BazelJavaBuilder.java:45)
Caused by: java.nio.file.DirectoryNotEmptyException: bazel-out\x64_windows-fastbuild\bin\src\main\java\com\google\devtools\build\skyframe\_javac\skyframe\libskyframe_classes\com\google\devtools\build
at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:266)
at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
at java.nio.file.Files.delete(Files.java:1126)
at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder$1.postVisitDirectory(SimpleJavaLibraryBuilder.java:85)
at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder$1.postVisitDirectory(SimpleJavaLibraryBuilder.java:73)
at java.nio.file.Files.walkFileTree(Files.java:2688)
at java.nio.file.Files.walkFileTree(Files.java:2742)
at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.cleanupDirectory(SimpleJavaLibraryBuilder.java:71)
... 6 more
Target //src:bazel failed to build
INFO: Elapsed time: 36.284s, Critical Path: 14.20s
INFO: 44 processes: 23 local, 21 worker.
FAILED: Build did NOT complete successfully
pcloudy@pcloudy0-w MSYS ~/workspace/bazel
$ bazel clean
Starting local Bazel server and connecting to it...
INFO: Starting clean.
ERROR: C:/users/pcloudy/_bazel_pcloudy/3uxo2r6v/execroot/io_bazel/bazel-out/x64_windows-fastbuild/bin/src/main/java/com/google/devtools/build/lib/remote/blobstore/_javac/blobstore/libblobstore_classes/com/google (Directory not empty)
pcloudy@pcloudy0-w MSYS ~/workspace/bazel
$ ls /c/users/pcloudy/_bazel_pcloudy/3uxo2r6v/execroot/io_bazel/bazel-out/x64_windows-fastbuild/bin/src/main/java/com/google/devtools/build/lib/remote/blobstore/_javac/blobstore/libblobstore_classes/com/google
pcloudy@pcloudy0-w MSYS ~/workspace/bazel
$ bazel clean
INFO: Starting clean.
ERROR: C:/users/pcloudy/_bazel_pcloudy/3uxo2r6v/execroot/io_bazel/bazel-out/x64_windows-fastbuild (Directory not empty)
pcloudy@pcloudy0-w MSYS ~/workspace/bazel
$ bazel clean
INFO: Starting clean.
FYI @laszlocsomor
Does bazel clean eventually succeed?
Yes, it took me three times although.
Can you repro reliably?
It happens constantly for me in the following situation:
# Clone bazel repo @ HEAD
$ bazel build //src:bazel
$ git reset 4c9149d --hard
$ bazel build //src:bazel
But I'm using 0.15.2, I'll try if it still happens with 0.16.1
I believe @meteorcloudy is working on this -- reassigning.
@meteorcloudy , have you seen this error with recent releases?
I haven't seen this after setting my output user root to C:/src/tmp, I guess it has something to do with the Windows Defender. I didn't receive any bug report from users, either. So I think it's fine to close issue.
Reopen since @laszlocsomor and I have both been seeing this issue for a while again, I'll look into it.
Related stackoverflow question: https://stackoverflow.com/questions/31606978/odd-behaviour-when-deleting-files-with-files-delete
Related stackoverflow question: https://stackoverflow.com/questions/31606978/odd-behaviour-when-deleting-files-with-files-delete
That was a great read, thanks!
@meteorcloudy : Can we close this bug?
ping
@laszlocsomor Sorry for the late response. Not yet, because in the JavaSimpleLibraryBuilder I sometimes still get DirectoryNotEmpty exception while rebuilding. It is not using our JNI code to delete file and directory, instead it uses MoreFiles.deleteRecursively from guava.
Did you ever have the same error?
Thanks for the update!
I don't remember clearly anymore if I've seen it or not.
Basically I can reproduce after about 50 commits change in Bazel repo,
eg.
$ bazel build //src:bazel
$ git reset HEAD~50 --hard
$ bazel build //src:bazel
@meteorcloudy : Any updates? Is P1 still adequate?
I am not working on this recently. I'm not getting any report from users, so I guess P2 should be more appropriate. But I can still reproduce this bug on my local machine, so I'll keep it open.
Hey @meteorcloudy , I'd like to take a look at this. Can you still repro this locally? Could you help me repro?
@laszlocsomor , thanks!
Yes, I can still repo this, basically following https://github.com/bazelbuild/bazel/issues/5907#issuecomment-413482068
Just reset to an old enough commit which will trigger a rebuild for most of Java code.
This issue will be fixed from guava side, there's internal work going on, so I'm closing this one.