GithubHelp home page GithubHelp logo

Comments (3)

fmeum avatar fmeum commented on July 20, 2024

Prior to Bazel v7, .download and .download_and_extract were beholden to the flag --experimental_repository_cache_urls_as_default_canonical_id...

This is correct. As of Bazel 7, the flag is now a no-op and the repo rules you listed have been updated to use this logic by default.

... which in Bazel v6 (and possibly earlier) was enabled by default.

This is not correct, the flag wasn't enabled by default in previous versions of Bazel:
https://cs.opensource.google/bazel/bazel/+/release-6.5.0:src/main/java/com/google/devtools/build/lib/bazel/repository/RepositoryOptions.java;l=243

If you are using rctx.download or rctx.download_and_extract in a custom repo rule and were previously using the --experimental_repository_cache_urls_as_default_canonical_id flag to set a default canonical ID, you would have to update the logic to manually pass URLs into the canonical ID field. You can use the new public helper function get_default_canonical_id in @bazel_tools//tools/build_defs/repo:cache.bzl if you want to match the behavior of the special-cased rules.

from bazel.

Silic0nS0ldier avatar Silic0nS0ldier commented on July 20, 2024

Ah, my mistake. Perhaps the flag had been in use in our repo, or perhaps I had simply made a bad assumption.

In this case I have some suggestions;

  • rctx.download* documentation should be updated to include what the default canonical_id is.
  • rctx.download* documentation should include examples for common patterns (such as using get_default_canonical_id).
  • Co-ordinate with ruleset authors so API usage uses an appropriate canonical_id (not having it set is probably a good signal that the behaviour hasn't been considered).

Some extra context for my request which I neglected to include in the OP. Due to the default behaviour, a TypeScript version upgrade was merged in a broken state due to an overlooked integrity hash.

load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies")
rules_ts_dependencies(
    ts_version_from = "//:package.json", # 5.4.2 -> 5.4.5
-   ts_integrity = "sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==",
+   ts_integrity = "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==",
)

This specific instance of the issue should not reoccur as we've updated usage to automatically pick up the hash.

rules_ts_dependencies(
    ts_version_from = "@pnpm//:typescript/resolved.json",
)

from bazel.

Silic0nS0ldier avatar Silic0nS0ldier commented on July 20, 2024

I looked into using @bazel_tools//tools/build_defs/repo:cache.bzl in an internal repo rule, without success. The helper has visibility("private") preventing usage, it is not currently part of the public API.

from bazel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.