-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flag to include URLs in repository cache key when canonical_id not specified #14128
Comments
…elp detect broken repository URLs This new flag can be used to force redownloading when repository URLs are changed. Otherwise, it's possible broken URLs can be masked by the presence of a repository cache entry with the same hash. Specifying a `canonical_id` works as before, overriding this behavior. Closes bazelbuild#14128.
cc: @davido @meteorcloudy |
@aiuto Thanks for the pointer. @kmicklas Thanks, this is really good idea and is overdue (and should be even flipped to true per default in later Bazel releases). I cherry-picked your PR and applied it to Gerrit Code Review project. This worked as expected and flaged the incomplete dependency update and fail the build (and this is great). Consider this (bad) diff: diff --git a/WORKSPACE b/WORKSPACE
index bbc236780b..b031d60130 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -56,10 +56,18 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()
+#http_archive(
+# name = "build_bazel_rules_nodejs",
+# canonical_id = "https://github.com/bazelbuild/rules_nodejs/releases/download/3.5.0/rules_nodejs-3.5.0.tar.gz",
+# sha256 = "10f534e1c80f795cffe1f2822becd4897754d18564612510c59b3c73544ae7c6",
+# urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.5.0/rules_nodejs-3.5.0.tar.gz"],
+#)
+
http_archive(
name = "build_bazel_rules_nodejs",
+ #canonical_id = "https://github.com/bazelbuild/rules_nodejs/releases/download/4.6.0/rules_nodejs-4.6.0.tar.gz",
sha256 = "10f534e1c80f795cffe1f2822becd4897754d18564612510c59b3c73544ae7c6",
- urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.5.0/rules_nodejs-3.5.0.tar.gz"],
+ urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.6.0/rules_nodejs-4.6.0.tar.gz"],
) The external dependency With latest Bazel@HEAD (d67dc88), build Gerrit
With your PR and with option flipped:
[1] https://gerrit.googlesource.com/gerrit/+/refs/heads/master/WORKSPACE#60 |
…elp detect broken repository URLs This new flag can be used to force redownloading when repository URLs are changed. Otherwise, it's possible broken URLs can be masked by the presence of a repository cache entry with the same hash. Specifying a `canonical_id` works as before, overriding this behavior. Closes bazelbuild#14128. Closes bazelbuild#14268. PiperOrigin-RevId: 420976730 (cherry picked from commit f9882e4)
…elp detect broken repository URLs (#14989) This new flag can be used to force redownloading when repository URLs are changed. Otherwise, it's possible broken URLs can be masked by the presence of a repository cache entry with the same hash. Specifying a `canonical_id` works as before, overriding this behavior. Closes #14128. Closes #14268. PiperOrigin-RevId: 420976730 (cherry picked from commit f9882e4) Co-authored-by: Ken Micklas <kmicklas@uber.com>
Description of the problem / feature request:
It would be nice to have a flag, e.g.
--experimental_use_urls_as_default_canonical_id
, which includes the URLs in the repository cache key ifcanonical_id
isn't set manually in the call todownload
/download_and_extract
. This can be used in a CI system to verify that invalid repository updates don't get checked in.Feature requests: what underlying problem are you trying to solve with this feature?
It seems that users frequently run into issues with repository rules using cached downloads based on SHA256 despite some other detail (especially URLs) being changed and making it invalid. This isn't noticed until building without that cache entry. See #10630, #10612, #10353, #5144.
The way to prevent this is to use
canonical_id
to force redownloading, for example by setting it to the URL. The problem is that requiring developers to setcanonical_id
is prone to error. You could make custom wrappers for e.g.http_file
to automatically use the URL ascanonical_id
, but in a large codebase it's possible this will be accidentally circumvented with the upstream rule definition.What operating system are you running Bazel on?
macOS 11.6
What's the output of
bazel info release
?The text was updated successfully, but these errors were encountered: