bazelbuild/bazel

Installation broken on Ubuntu 16.04

jgarvin opened this issue ยท 8 comments

I followed the installation instructions to add the repository using jdk1.8. During the update step there is a warning complaining about i386 packages, even though I'm running 64-bit. I continued but this obviously should be fixed.

The install step results in jdk1.9 being installed automatically for some reason (is the dependency for the bazel declared wrong?), leading to this known error when you try to run:

Problem with java installation: couldn't find/access rt.jar in /usr/lib/jvm/java-9-openjdk-amd64

Manually installing openjdk-8-jdk and removing openjdk-9-jdk and running update-alternatives in order to make sure that 8 is used still doesn't fix the issue, the same error appears.

So then I tried the manual sh installer. If I run it with "sh bazel-0.3.0-installer-linux-x86_64.sh" it prints a partial change log before failing with:

bazel-0.3.0-installer-linux-x86_64.sh: 77: bazel-0.3.0-installer-linux-x86_64.sh: Syntax error: "(" unexpected

If instead I try to run with "./bazel-0.3.0-installer-linux-x86_64.sh" the script appears to background itself and stop:

[5] 30269
[5]  + suspended (tty output)  sh -c less\ \'./bazel-0.3.0-installer-linux-x86_64.sh\'

At this point I gave up and went back to cmake.

Bazel's deb package declares 'java8-sdk' as a dependency, but accroding to http://packages.ubuntu.com/xenial/java8-sdk openjdk-9-jdk is also providing this virtual package on Ubuntu 16.04. However, that's not the case on Ubuntu 15.10, to adapt this change we will find a way to exclude openjdk-9-jdk soon.

But fortunately, there is still a simple workaround for your case.
Which is to completely remove openjdk-9 stuff by running:
sudo apt-get purge openjdk-9*

After this, if openjdk-8 is installed, bazel should work fine.

If java and javac can't be found in shell anymore, you can fix it by following command:

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/java-8-openjdk-amd64/bin/javac" 1
sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac

the purge command worked for me thanks :)

Exactly the same issue here on Ubuntu 16.04 ...
Current Bazel master > 0.4.4 ...

How can I build Bazel from scratch, with jdk1.9, instead of just follow the description like: https://alliseesolutions.wordpress.com/2016/09/08/install-gpu-tensorflow-from-sources-w-ubuntu-16-04-and-cuda-8-0-rc/ ???

@jiapei100 Sorry, Bazel doesn't support jdk1.9 yet, is jdk1.8 an option for you?

And can you try export JAVA_VERSION=1.7 before building bazel? It might help.

This is still a problem with the Bazel 0.6.1 package on a clean Ubuntu 16.04.3.

Happened to me for Bazel 0.7.0

For anyone interested I managed avoiding the jdk 9 install by using the following command:

sudo apt-get install bazel openjdk-9-jdk-

Make sure to add the "-" after openjdk-9-jdk.