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

bazel downloads the JDK during execution #6865

Closed
sergiocampama opened this issue Dec 7, 2018 · 8 comments
Closed

bazel downloads the JDK during execution #6865

sergiocampama opened this issue Dec 7, 2018 · 8 comments
Labels
team-Bazel General Bazel product/strategy issues untriaged

Comments

@sergiocampama
Copy link
Contributor

ATTENTION! Please read and follow:

Description of the problem / feature request:

When running tests with bazel, it tries to download some JDK. This makes bazel dependent on connectivity in order to run. In our case, we do have connectivity to the internet, but if there are transitive errors when trying to download the JDK, the tests will fail. If there are no errors, it still adds extra time to the tests, which is not ideal.

Why is this needed? Can't bazel be completely hermetic and not require runtime downloads?

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

https://travis-ci.org/bazelbuild/rules_apple/jobs/464988085

What operating system are you running Bazel on?

macOS / Travis

If bazel info release returns "development version" or "(@non-git)", tell us how you built Bazel.

Using bazel at "head" from the nightly releases.

@sergiocampama
Copy link
Contributor Author

sergiocampama commented Dec 7, 2018

This is the actual error line we're getting:

/private/var/tmp/_bazel_travis/2b80b7ac301f661b0fa17c1c94402319/execroot/build_bazel_rules_apple/_tmp/c740a88c54849b35c3371966379e4d43/_bazel_travis/58f5ae0bd4f5d2153c1b56727890a337/external/bazel_tools/tools/jdk/BUILD:305:1:

no such package '@remotejdk_macos//': java.io.IOException:

Error downloading [https://mirror.bazel.build/openjdk/azul-zulu-9.0.7.1-jdk9.0.7/zulu9.0.7.1-jdk9.0.7-macosx_x64-allmodules.tar.gz] to /private/var/tmp/_bazel_travis/2b80b7ac301f661b0fa17c1c94402319/execroot/build_bazel_rules_apple/_tmp/c740a88c54849b35c3371966379e4d43/_bazel_travis/58f5ae0bd4f5d2153c1b56727890a337/external/remotejdk_macos/zulu9.0.7.1-jdk9.0.7-macosx_x64-allmodules.tar.gz:

Unknown host: mirror.bazel.build and referenced by '@bazel_tools//tools/jdk:remote_jdk'

@cushon
Copy link
Contributor

cushon commented Dec 7, 2018

cc @meisterT

This is the result of #6656.

@jin jin added untriaged team-Bazel General Bazel product/strategy issues labels Dec 10, 2018
@meisterT
Copy link
Member

This is intentional, we're not longer exposing the embedded JDK that we use to run bazel as host_jdk. You can explicitly set the --host_javabase if you want to avoid downloads, e.g., to @local_jdk//:jdk.

Profpatsch added a commit to Profpatsch/nixpkgs that referenced this issue Jan 10, 2019
0.21 removed the bundled openjdk-distribution. Instead, tries to fetch
the “right” distribution on-the-fly when building.
So we need to provide our own openjdk.

According to
bazelbuild/bazel#6865 (comment)
we should set `--host_javabase="@local_jdk//:jdk` if we want to do
that. This uses the jdk that is currently in the environment, which is
openjdk 8 in our case. 0.21 defaulted to a toolchain for JDK9, which
we don’t package in nixpkgs, so we use the JDK8 toolchain.

This commit also replaces the line-number-based sed invocations with
something more stable.
Profpatsch added a commit to NixOS/nixpkgs that referenced this issue Jan 10, 2019
0.21 removed the bundled openjdk-distribution. Instead, tries to fetch
the “right” distribution on-the-fly when building.
So we need to provide our own openjdk.

According to
bazelbuild/bazel#6865 (comment)
we should set `--host_javabase="@local_jdk//:jdk` if we want to do
that. This uses the jdk that is currently in the environment, which is
openjdk 8 in our case. 0.21 defaulted to a toolchain for JDK9, which
we don’t package in nixpkgs, so we use the JDK8 toolchain.

This commit also replaces the line-number-based sed invocations with
something more stable.
@jeb2239
Copy link

jeb2239 commented Feb 12, 2019

I don't think --host_javabase exists anymore is there an alternative way to prevent jdk downloads given there is a jdk on the machine.

@meisterT
Copy link
Member

@jeb2239 --host_javabase still exists. You might have been confused by incompatible_use_jdk11_as_host_javabase which just switches the default host_javabase but doesn't remove the option to set your own.

@jeb2239
Copy link

jeb2239 commented Feb 13, 2019

is this supposed to be a startup option? What should it be set too if I want to stop all downloads of jdks? I have JAVA_HOME set to my local java install. I have tried pointing --host_javabase to various things but I keep getting an option doesn't exist error.

@meisterT
Copy link
Member

No it's not a startup option, see https://docs.bazel.build/versions/master/user-manual.html#flag--host_javabase.

bazel build --host_javabase=@local_jdk//:jdk //path/to/your:target should work and not download any JDK.

@jhinrichsen
Copy link

I ran into the same problem and this runs just fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Bazel General Bazel product/strategy issues untriaged
Projects
None yet
Development

No branches or pull requests

6 participants