bazelbuild / bazelisk

A user-friendly launcher for Bazel.
Apache License 2.0
2.08k stars 317 forks source link

Bazelisk corrupts the bazel installation if it's run multiple times concurrently #436

Open jfirebaugh opened 1 year ago

jfirebaugh commented 1 year ago

I was trying to use Bazelisk in a CI setup where multiple CI agents run on a single instance. I observed the following error when multiple bazelisk processes attempt to install bazel concurrently:

2023/03/09 02:31:53 Downloading https://releases.bazel.build/6.0.0/release/bazel-6.0.0-linux-x86_64...
Opening zip "/var/lib/buildkite-agent/.cache/bazelisk/downloads/bazelbuild/bazel-6.0.0-linux-x86_64/bin/bazel (deleted)": open(): No such file or directory
FATAL: Failed to open '/var/lib/buildkite-agent/.cache/bazelisk/downloads/bazelbuild/bazel-6.0.0-linux-x86_64/bin/bazel (deleted)' as a zip file: (error: 2): No such file or directory
dhirajtobii commented 7 months ago

@fweikert Do we have any solution or work around to avoid this crash.

sfc-gh-rnosovich commented 3 months ago

@fweikert any news related to this issue?

dhirajtobii commented 3 months ago

@fweikert Do we have any solution or work around to avoid this crash.

Try to sych cache in different host directory

nchepanov commented 1 month ago

I'm observing this as well, exactly as described, bazelisk version v1.19.0

nchepanov commented 1 month ago

FYI, we worked around this problem by setting BAZELISK_HOME per Jenkins workspace. Similar approach is possible with maybe using BUILDKITE_AGENT_NAME that I believe is required to be unique per agent within a host

export BAZELISK_HOME="${ctx.WORKSPACE}/.bazelisk"
bazel run ...