rules_go icon indicating copy to clipboard operation
rules_go copied to clipboard

Make MODULE.bazel.lock file have the same contents no matter the platform bazel is executed on

Open leungster opened this issue 1 year ago • 1 comments

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.

leungster avatar Jan 05 '24 05:01 leungster

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 avatar Jan 06 '24 08:01 fmeum

@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.

stefanpenner avatar May 23 '24 15:05 stefanpenner

Oh, nvm I found the design doc: https://docs.google.com/document/d/1TjA7-M5njkI1F38IC0pm305S9EOmxcUwaCIvaSmansg/edit#heading=h.5mcn15i0e1ch

stefanpenner avatar May 23 '24 15:05 stefanpenner

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

fmeum avatar May 23 '24 15:05 fmeum

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.

leungster avatar May 23 '24 22:05 leungster

Yup this seems fixed for us as well. I’ll keep an eye out, and report if we notice anything

stefanpenner avatar Jun 05 '24 11:06 stefanpenner