rules_go
rules_go copied to clipboard
Make MODULE.bazel.lock file have the same contents no matter the platform bazel is executed on
What version of rules_go are you using?
0.44.1
What version of gazelle are you using?
0.35.0
What version of Bazel are you using?
Bazel 7.0.0
Does this issue reproduce with the latest releases of all the above?
Yes
What operating system and processor architecture are you using?
OSX ARM and Linux x86
What did you do?
I'm running into a similar issue as https://github.com/bazelbuild/bazel/issues/19154 where developers are building on a mix of osx x86 and arm64 processors, while our CI is using Linux x86.
When our project is built on each platform, the MODULE.bazel.lock extensions are only update for the host platform. e.g. We get an entry such as the following
"@@rules_go~0.44.1//go:extensions.bzl%go_sdk": {
"os:osx,arch:aarch64": {
Since we're trying to keep the lockfile in version control, it's not possible to keep this up to date across all the build environments. It looks like rules_python has a similar issue..
What did you expect to see?
MODULE.bazel.lock is the same regardless of which platform we're running bazel.
What did you see instead?
The lock file is different based on the host platform.
This is on my radar, but I plan to solve it by excluding the go_sdk extension from the lock file altogether. It is fully deterministic and essentially static, so it doesn't gain much from being locked. This requires a Bazel design doc that I'm planning to draft soon.
For the meantime I don't have a good solution: We do have to record the "platform -> SDK" mapping for Gazelle and that may involve querying the host platform.
@fmeum nice, great to hear this is on your radar. When that bazel design doc is up, please do link it here I would love to give it a read.
Oh, nvm I found the design doc: https://docs.google.com/document/d/1TjA7-M5njkI1F38IC0pm305S9EOmxcUwaCIvaSmansg/edit#heading=h.5mcn15i0e1ch
This should be fixed with latest rules_go and Bazel 7.1.2. Please give it a try.
Edit: https://docs.google.com/document/d/1TjA7-M5njkI1F38IC0pm305S9EOmxcUwaCIvaSmansg/edit
I can confirm it's fixed with the latest rules_go and Bazel 7.1.2.
It still persists with rules_python and pip but that's captured in another issue.
Yup this seems fixed for us as well. I’ll keep an eye out, and report if we notice anything