Closed adamhowardprice closed 5 years ago
I am unable to reproduce this on macOS with Bazel 0.24.1, although I can see that bazel-out/darwin-fastbuild/bin/examples/android/java/bazel/_dx/hello_world/extracted_hello_world_deploy.jar
is an empty jar, which is probably causing singlejar to choke here: https://source.bazel.build/bazel/+/master:src/tools/singlejar/input_jar.cc;l=31?q=f:singlejar%20%22bytes%20long%22
$ zipinfo bazel-out/darwin-fastbuild/bin/examples/android/java/bazel/_dx/hello_world/extracted_hello_world_deploy.jar
Archive: bazel-out/darwin-fastbuild/bin/examples/android/java/bazel/_dx/hello_world/extracted_hello_world_deploy.jar
Zip file size: 22 bytes, number of entries: 0
Empty zipfile.
@adamhowardprice what does zipinfo
return on the file on your side? My empty jar is 22bytes long, which is the expected size of an empty jar.
zipinfo ../../bazel-out/darwin-fastbuild/bin/examples/android/java/bazel/_dx/hello_world/extracted_hello_world_deploy.jar
Archive: ../../bazel-out/darwin-fastbuild/bin/examples/android/java/bazel/_dx/hello_world/extracted_hello_world_deploy.jar
[../../bazel-out/darwin-fastbuild/bin/examples/android/java/bazel/_dx/hello_world/extracted_hello_world_deploy.jar]
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
note: ../../bazel-out/darwin-fastbuild/bin/examples/android/java/bazel/_dx/hello_world/extracted_hello_world_deploy.jar may be a plain executable, not an archive
zipinfo: cannot find zipfile directory in one of ../../bazel-out/darwin-fastbuild/bin/examples/android/java/bazel/_dx/hello_world/extracted_hello_world_deploy.jar or
../../bazel-out/darwin-fastbuild/bin/examples/android/java/bazel/_dx/hello_world/extracted_hello_world_deploy.jar.zip, and cannot find ../../bazel-out/darwin-fastbuild/bin/examples/android/java/bazel/_dx/hello_world/extracted_hello_world_deploy.jar.ZIP, period.
Just to confirm, is it a 0-byte file?
Yes
Do you happen to have any kind of system-wide programs that can affect file content? Like an anti-virus or backup software?
I do have some anti-virus software that is running against my will :)
Interesting theory -- how can I figure out if that's interfering with this?
I reached out to my IT team
AFAIK, that's typically the cause of involuntary 0-byte files. Do you have a way to disable it? Does the problem also occur on other Macs running the same base macOS image?
Deleted the antivirus program and this is still failing
Does this occur on other Macs?
Unfortunately, I'm not able to reproduce this on Mojave 10.14. Curious that this only happens to jar files. What's your local JDK version (javac -version
)?
Figured it out offline with @adamhowardprice: this will occur if you are using Python versions earlier than 2.7.1.
https://stackoverflow.com/questions/25195495/how-to-create-an-empty-zip-file
For Python tools that create zipfiles, if running on Python versions earlier than 2.7.1, the zipfile library will not create the base zip structure in the empty zip file, leading to a 0 byte file.
On and after 2.7.1, the empty zip file has a valid zip structure.
The workaround is to upgrade the system Python to 2.7.1 or later. But note that Python 2.7 is EOLing soon, so it's unlikely we'll backport support for this.
Description of the problem / feature request:
Android bazel builds are failing for me with 0.24.1. Seen on my project and reproduced with the Android example Hello World project in this repo.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
I run:
$ bazel build --verbose_failures //examples/android/java/bazel:hello_world
and the output is
What operating system are you running Bazel on?
MacOS Mojave 10.14.4 Beta
What's the output of
bazel info release
?release 0.24.1
What's the output of
git remote get-url origin ; git rev-parse master ; git rev-parse HEAD
?https://github.com/bazelbuild/bazel.git e91ac8d44fb994dfbd0437c8b98f5dded78a2f2e e91ac8d44fb994dfbd0437c8b98f5dded78a2f2e
Any other information, logs, or outputs that you want to share?
In another Android project, when I attempted to build, I got this error: