bazelisk icon indicating copy to clipboard operation
bazelisk copied to clipboard

Get bazelisk version without launching bazel server

Open blackliner opened this issue 2 years ago • 2 comments

We are looking for a fast way to determine the version of the bazelisk binary. Calling time bazel version currently prints the following:

Bazelisk version: v1.16.0
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.1.1
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Mar 15 15:44:56 2023 (1678895096)
Build timestamp: 1678895096
Build timestamp as int: 1678895096

real    0m1.372s
user    0m2.208s
sys     0m0.259s

It takes some time for bazel to start the local server, but in our case we do not need to know the bazel version (because we define it via .bazelversion). We only need the first line: Bazelisk version: v1.16.0

blackliner avatar Mar 20 '23 16:03 blackliner

Any updates here? Even a fresh download of bazelisk has to download bazel before spitting out the bazelisk version

blackliner avatar Nov 20 '23 15:11 blackliner

BTW. This old https://github.com/bazelbuild/bazelisk/issues/137 issue/feature request, essentially, wants to achieve the same thing.

I was looking for a way to do exactly that, recently. I took a look at the source code and if contributions are accepted I might open a PR since it should be relatively simple to implement.

mariusz-wlodarczyk avatar Sep 19 '24 07:09 mariusz-wlodarczyk