Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to build on Ubuntu #3782

Open
aquynh opened this issue Mar 11, 2021 · 3 comments
Open

Fail to build on Ubuntu #3782

aquynh opened this issue Mar 11, 2021 · 3 comments

Comments

@aquynh
Copy link

aquynh commented Mar 11, 2021

I am trying to build the latest code from github on Ubuntu 20.04, and get the following error.

$ bazelisk build :all
....
INFO: Analyzed 424 targets (0 packages loaded, 0 targets configured).
INFO: Found 424 targets...
ERROR: /home/me/.cache/bazel/_bazel_me/e101812331eb46b601b8487dfb6ffce9/external/bazel_tools/tools/jdk/BUILD:314:1: Action external/bazel_tools/tools/jdk/platformclasspath.jar failed (Exit 1)
Exception in thread "main" java.lang.IllegalArgumentException: external/local_jdk
	at jdk.compiler/com.sun.tools.javac.file.Locations$SystemModulesLocationHandler.update(Locations.java:1853)
	at jdk.compiler/com.sun.tools.javac.file.Locations$SystemModulesLocationHandler.handleOption(Locations.java:1798)
	at jdk.compiler/com.sun.tools.javac.file.Locations.handleOption(Locations.java:2062)
	at jdk.compiler/com.sun.tools.javac.file.BaseFileManager.handleOption(BaseFileManager.java:269)
	at jdk.compiler/com.sun.tools.javac.file.BaseFileManager$2.handleFileManagerOption(BaseFileManager.java:222)
	at jdk.compiler/com.sun.tools.javac.main.Option.process(Option.java:1138)
	at jdk.compiler/com.sun.tools.javac.main.Option.handleOption(Option.java:1086)
	at jdk.compiler/com.sun.tools.javac.file.BaseFileManager.handleOption(BaseFileManager.java:232)
	at jdk.compiler/com.sun.tools.javac.main.Arguments.doProcessArgs(Arguments.java:390)
	at jdk.compiler/com.sun.tools.javac.main.Arguments.processArgs(Arguments.java:347)
	at jdk.compiler/com.sun.tools.javac.main.Arguments.init(Arguments.java:246)
	at jdk.compiler/com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:185)
	at DumpPlatformClassPath.dumpJDK9AndNewerBootClassPath(DumpPlatformClassPath.java:106)
	at DumpPlatformClassPath.main(DumpPlatformClassPath.java:67)
INFO: Elapsed time: 1.274s, Critical Path: 0.71s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

Here is my java version:

$ java --version
openjdk 14.0.2 2020-07-14
OpenJDK Runtime Environment (build 14.0.2+12-Ubuntu-120.04)
OpenJDK 64-Bit Server VM (build 14.0.2+12-Ubuntu-120.04, mixed mode, sharing)

Any ideas on how to fix this issue?

@brad4d
Copy link
Contributor

brad4d commented Mar 11, 2021

The development environment on which the Google support team works on closure-compiler is using JDK 11.

$ java --version
openjdk 11.0.10 2021-02-27
OpenJDK Runtime Environment (build 11.0.10+9-google-release-359977778)
OpenJDK 64-Bit Server VM (build 11.0.10+9-google-release-359977778, mixed mode, sharing)

Hmmm.... it looks like it's actually bazelisk or bazel that failed.
Maybe bazel has a problem with Java 14?
It might be better to file a bug with the bazel project.

https://github.com/bazelbuild/bazel/issues

@aquynh
Copy link
Author

aquynh commented Mar 12, 2021

i tried to build with yarn, but also get error like below.

$ yarn build
yarn run v1.22.10
$ clean && mvn -DskipTests
/bin/sh: 1: clean: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@neekfenwick
Copy link

perhaps you do not have javac on your $PATH? i.e. you need to install a JDK that has the java compiler binary javac.

I got a very similar looking error message, with openjdk 11 installed on my Fedora 34 system:

INFO: Analyzed target //:compiler_unshaded_deploy.jar (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /home/neek/.cache/bazel/_bazel_neek/ca9166dfb359be451c95c9d1c6288e98/external/bazel_tools/tools/jdk/BUILD:314:1: Action external/bazel_tools/tools/jdk/platformclasspath.jar failed (Exit 1): java failed: error executing command 
  (cd /home/neek/.cache/bazel/_bazel_neek/ca9166dfb359be451c95c9d1c6288e98/execroot/com_google_javascript_jscomp && \
  exec env - \
  external/remotejdk11_linux/bin/java -XX:+IgnoreUnrecognizedVMOptions '--add-exports=jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED' -cp bazel-out/k8-fastbuild/bin/external/bazel_tools/tools/jdk/platformclasspath_classes:external/remotejdk11_linux/lib/tools.jar DumpPlatformClassPath bazel-out/k8-fastbuild/bin/external/bazel_tools/tools/jdk/platformclasspath.jar external/local_jdk)
Execution platform: @local_config_platform//:host
Exception in thread "main" java.lang.IllegalArgumentException: external/local_jdk
        at jdk.compiler/com.sun.tools.javac.file.Locations$SystemModulesLocationHandler.update(Locations.java:1853)
        at jdk.compiler/com.sun.tools.javac.file.Locations$SystemModulesLocationHandler.handleOption(Locations.java:1798)

I thought perhaps it was my java version number at fault, from this output I thought I had a full JDK installed:

$ java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment 18.9 (build 11.0.11+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.11+9, mixed mode, sharing)

Just to try something, I downloaded JDK 16 following these insturctions https://www.techtransit.org/install-and-upgrade-java-version-on-centos-redhat-and-fedora-linux/ (untar the JDK and use alternatives to point /usr/bin links to them, and I found that javac had not been set to anything previously, and sure enough my Fedora package java-11-openjdk-headless doesn't have a javac binary in it.

After installing a "proper" JDK and setting up javac on my $PATH, the bazel build completes OK.

Bazel appears to have poor error reporting going back a few years, see google/j2cl#34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants