KSMoon
KSMoon

Reputation: 21

How can I instal bazel on Ubuntu 22.04 with parallels M1 mac

I'm trying to install bazel on Ubuntu 22.04

I followed install steps on https://bazel.build/install/ubuntu

I followed "Using Bazel's apt repository" and when I "sudo apt install bazel", E: Unable to locate package bazel error exists

Also I followed "Using the binary installer" and on step "chmod +x bazel-6.2.1-installer-linux-x86_64.sh", "./bazel-6.2.1-installer-linux-x86_64.sh --user". and "line 223: /home/parallels/.bazel/bin/bazel-real: cannot execute binary file: Exec format error" exists.

How can I install bazel...

Upvotes: 1

Views: 2968

Answers (1)

Vertexwahn
Vertexwahn

Reputation: 8152

Use Bazelisk instead of Bazel. Bazelisk will download the newest LTS Bazel version for you and use it.

On Ubuntu 22.04 you can download and move it to a place that is accessible by:

apt install wget
wget https://github.com/bazelbuild/bazelisk/releases/download/v1.17.0/bazelisk-linux-arm64
chmod +x bazelisk-linux-arm64
mv bazelisk-linux-arm64 /usr/local/bin/bazel

To check if Bazel is working you can run:

bazel version

Should output something like

Bazelisk version: development
WARNING: Invoking Bazel in batch mode since it is not invoked from within a workspace (below a directory having a WORKSPACE file).
Build label: 6.2.1
Build target: bazel-out/darwin_arm64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Jun 2 17:00:10 2023 (1685725210)
Build timestamp: 1685725210
Build timestamp as int: 1685725210

Further notes: At the time of writing this the newest Bazelisk version is/was v1.17.0. Feel free to update the version to a newer release (if a newer one exists)

Upvotes: 0

Related Questions