bazelbuild / bazelisk

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

Changing BAZELISK_FORMAT_URL does not trigger re-downloading Bazel #488

Open kjteske opened 11 months ago

kjteske commented 11 months ago

Using bazelisk v1.17.0, changing BAZELISK_FORMAT_URL does not trigger re-downloading Bazel if the same version number of Bazel has previously been downloaded from anywhere.

# Start off clean
rm -f .bazelversion
rm -f .bazeliskrc
rm -rf ~/.cache/bazelisk/downloads/bazelbuild

# Download official/upstream Bazel 6.3.1
USE_BAZEL_VERSION=6.3.1 bazelisk --version
# Outputs:
#   2023/08/11 10:05:46 Downloading https://releases.bazel.build/6.3.1/release/bazel-6.3.1-linux-x86_64...
#   bazel 6.3.1

# Switch to our internally-built and published URL
cat > .bazeliskrc <<EOL
BAZELISK_FORMAT_URL=<our internal URL>
USE_BAZEL_VERSION=6.3.1
EOL
bazelisk --version
# Outputs:
#   bazel 6.3.1
# We expect this to download from our internal URL, but it does not

Workaround: we can use BAZELISK_BASE_URL, but then we have to conform to the usual URL format.

Changing BAZELISK_BASE_URL properly re-downloads - the code here changes the download directory if BaseURLEnv is set, but not if FormatURLEnv is set.