rules_rust icon indicating copy to clipboard operation
rules_rust copied to clipboard

Create universe MODULE.bazel input causes churn

Open sputt opened this issue 11 months ago • 5 comments

Referring to MODULE.bazel in a module_ctx when an extension is non-reproducible means the MODULE.bazel hash appears in the MODULE.bazel.lock. This is major churn, with any unrelated MODULE.bazel change triggering the rules rust extension and diff in the MODULE.bazel.lock file.

This needs to be updated to use some other mechanism to find the root. https://github.com/bazelbuild/rules_rust/blob/61f41867d5cada90aa7c415c8c3e550d51e8debe/crate_universe/extensions.bzl#L649

sputt avatar Jan 24 '25 18:01 sputt

Any plans to address this?

archshift avatar Mar 24 '25 18:03 archshift

This kinda fell off my radar but I did notice that this doesn't appear to be an issue in Bazel 8 as module_ctx.path doesn't watch files by default. If there's a simple fix for this that we can apply for Bazel 7 users then I'd be happy to do so but was unable to quickly come up with a solution last I thought about it.

UebelAndre avatar Mar 24 '25 18:03 UebelAndre

This being difficult to fix in Bazel 7 was exactly the motivation for the change in Bazel 8 that doesn't watch all Labels passed to module_ctx.path.

You could add a repo rule that uses this to get the path and exports it as a constant in .bzl file that your module extension then loads. That repo rule needs to be instantiated in a different module extension for this to work. The repo rule will rerun each time, but that should be relatively cheap.

fmeum avatar Mar 25 '25 16:03 fmeum

@fmeum would you happen to have a link to this change? And do you know if repository_ctx.path no longer watches as well?

UebelAndre avatar Mar 25 '25 23:03 UebelAndre

https://github.com/bazelbuild/bazel/commit/50196979346cb57bc2e239d8bcd5342d4000292e added the incompatible flag and yes, it also applies to the repo rule context.

fmeum avatar Mar 26 '25 10:03 fmeum