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 .deb package lists dependency on system JDK (unintentionally?) #5753

Closed
gertvdijk opened this issue Aug 3, 2018 · 7 comments
Closed
Labels
area-EngProd Bazel CI, infrastructure, bootstrapping, release, and distribution tooling team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged

Comments

@gertvdijk
Copy link
Contributor

Description of the problem / feature request:

Note that that 0.16.0 comes with an embedded JDK also for the .deb file (notice increased size from 100MB to 155MB).

I had the expectation that installing Bazel would drop the dependency on it for itself, so I can install and run Bazel without a local JDK installed.

However:

Unpacking bazel (0.16.0) ...
dpkg: dependency problems prevent configuration of bazel:
 bazel depends on google-jdk | java8-sdk-headless | java8-jdk | java8-sdk | oracle-java8-installer; however:
  Package google-jdk is not installed.
  Package java8-sdk-headless is not installed.
  Package java8-jdk is not installed.
  Package java8-sdk is not installed.
  Package oracle-java8-installer is not installed.

dpkg: error processing package bazel (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 bazel

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

  1. Get a clean Debian/Ubuntu machine (e.g. Docker/Vagrant or something).

  2. Install as per the documentation the dependencies, e.g.

     sudo apt-get -y --no-install-recommends install \
       g++ \
       pkg-config \
       python \
       unzip \
       zip \
       zlib1g-dev
    
  3. Download Bazel from the GitHub releases page - not the .sh file, but the .deb file.

  4. Install Bazel with dpkg, e.g. dpkg -i /path/to/downloaded/deb

What operating system are you running Bazel on?

Debian, Ubuntu.

What's the output of bazel info release?

Unable to install Bazel - so, nothing.

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

Obtained Bazel from GitHub release page

What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

n/a

Have you found anything relevant by searching the web?

#5744 - but that's pointing out that the need for a local JDK is a bug, underlining my statement in this report.

Any other information, logs, or outputs that you want to share?

If this dependency is deliberately kept in place, yet also shipping an embedded JDK, please update the documentation/resources explaining the need for that; the current situation does not compile in my head.

@jin
Copy link
Member

jin commented Aug 3, 2018

cc @philwo @buchgr

@gertvdijk
Copy link
Contributor Author

gertvdijk commented Aug 22, 2018

I had a little bit of a dive into the code and commit history on this today.

  • The amount of references in scripts/packages/debian/BUILD regarding without-jdk indicate to me that it has the intention of building a bazel without an embedded JDK and have a dependency on the system JDK (version 8). However, all other release artifact now depend on JDK 9, as far as I can tell.
  • Changes like 7c49bd9 indicate to me that embedding the JDK is a default since 0.16 and targets have been updated to do so.
  • The binary built in target ./bazel-out/k8-fastbuild/genfiles/scripts/packages/without-jdk/bazel-real - note the without-jdk in the path - appears to have an embedded JDK. My Bazel Skylark skills are not reaching the level yet that lets me understand why I see an embedded JDK with dependencies set on a rule having without-jdk in the name.
  • Having removed the JDK dependency myself and installed the built package in a clean Docker container without an JDK, it works and builds my projects. I think this proves it has an embedded JDK (or at least a JRE). See https://github.com/gertvdijk/bazel/commit/a6cda75bfcc1100be7d78a146fb1e81f19c7c105 for what I tried to build.

Other things, not completely related to the JDK, but encountered during my research:

  • libc dependency is missing (lintian tells me that, and more errors) - this results in spurious errors when trying to run it on an older Linux distribution than where you built it on. It clearly has a binary dependency on the host version.
  • version.txt is empty and build just continues with an empty version - it appears not to be given some git version as ./compile.sh would do, but I fail to understand why, as dependencies are set correctly. I managed to build a version setting the version myself in the pkg_deb rule.

Anyway, the current situation seems invalid to me. Please make a decision whether we want or do not want an embedded JDK in the Debian/Fedora packages.

@philwo
Copy link
Member

philwo commented Aug 28, 2018

We do want an embedded JDK in our Debian/Fedora packages. It's not clear yet, however, if we still have to depend (or at least optionally depend) on a system JDK as well in the long-term.

The reason is that currently the embedded JDK is a full JDK that's also compatible with the JavaBuilder that we ship. However, we're considering stripping down the embedded JDK to the bare minimum that's needed to run Bazel itself, at which point you'd need a system JDK (or a JDK from a remote repository) in order to build Java code.

Maybe we should change the "Depends" to a "Recommends" in our packages (if we verify that Bazel indeed currently works without an installed JDK, which is something that we don't test on CI yet)?

@gertvdijk
Copy link
Contributor Author

Thanks for clarifying, @philwo. IIUC:

  • it's not even an embedded JDK that Bazel is shipped with, but a JRE,
  • the embedded JDK/JRE is never designed to be used for compiling Java code.

Bazel isn't only used to build Java code, so for those environments not having that hard dependency would be great!

Making it a recommended (or suggested even) dependency makes sense, imo. Perhaps also consider adding the JDK 9/10/11 versions as well to the list (inside the big OR'd list), as recommending only JDK8 isn't the choice of everyone. I understand RPM/spec doesn't have a recommended/suggested level of dependencies, so yeah, I'm not so sure what would be the right thing to do there.

I'd volunteer to update the dependencies in a PR if we have consensus over what to do exactly.

if we verify that Bazel indeed currently works without an installed JDK, which is something that we don't test on CI yet

Is that something I can help with as well in a PR? If so, I'd appreciate some pointers where to look - I'm not yet familiar so much with Bazel's source tree.

@gertvdijk
Copy link
Contributor Author

I've com across the following in the 0.18.0-rc3 release notes:

Future versions of Bazel will require a locally installed JDK for Java development. Previously Bazel would fall back to using the embedded --server_javabase if no JDK as available.

I think it would not make sense for the Bazel project to be able to build special Bazel deb/rpm packages which try to use the local system JRE to run. First of all, because you cannot assume that all major mainline Linux distributions will provide the JRE Bazel needs. In order to have Bazel move forward without having to look at what all those Linux distributions are shipping, it makes sense to keep embedding the JDK (well, JRE then, if you can't build with it at all), including the deb/rpm packages.

TL;DR: Bazel deb/rpm packaging should drop the JDK dependencies (like I did in https://github.com/gertvdijk/bazel/commit/a6cda75bfcc1100be7d78a146fb1e81f19c7c105) and it's safe to do this at current HEAD, I think.

@aiuto aiuto added area-EngProd Bazel CI, infrastructure, bootstrapping, release, and distribution tooling team-Bazel General Bazel product/strategy issues and removed category: misc > release / binary labels Dec 5, 2018
@dslomov dslomov removed the area-EngProd Bazel CI, infrastructure, bootstrapping, release, and distribution tooling label Feb 15, 2019
@aiuto aiuto added this to the rules_package milestone May 29, 2019
@aiuto aiuto removed this from the rules_package milestone Jun 10, 2019
@aiuto aiuto added area-EngProd Bazel CI, infrastructure, bootstrapping, release, and distribution tooling untriaged and removed team-Bazel General Bazel product/strategy issues labels Jul 11, 2019
@riking
Copy link

riking commented Nov 3, 2019

Can the documentation at https://docs.bazel.build/versions/master/install-ubuntu.html be updated to mention that you don't need to edit jdk1.8 to jdk1.11 even if you're on a Java 11 system / Ubu18.04?

Note: The jdk1.8 in the command above is not related to the Java version installed in step 1.

bazel-io pushed a commit that referenced this issue Nov 18, 2019
…meaning.

This addresses user feedback from #5753 (comment).

PiperOrigin-RevId: 281059785
@meisterT
Copy link
Member

The dependency seems to be gone and the docs have been updated.

@philwo philwo added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-EngProd Bazel CI, infrastructure, bootstrapping, release, and distribution tooling team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged
Projects
None yet
Development

No branches or pull requests

7 participants