Skip to content
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

Uber's gomock 0.5.0 is incompatible with rules_go's gomock.bzl #4153

Open
TvdW opened this issue Oct 23, 2024 · 4 comments
Open

Uber's gomock 0.5.0 is incompatible with rules_go's gomock.bzl #4153

TvdW opened this issue Oct 23, 2024 · 4 comments

Comments

@TvdW
Copy link
Contributor

TvdW commented Oct 23, 2024

What version of rules_go/gazelle/bazel/gomock are you using?

  • rules_go 0.50.1 (latest)
  • gazelle 0.39.1 (latest)
  • bazel 7.3.1 (latest)
  • Uber's gomock 0.5.0 (latest)

What happened?

reflect mode got dropped, and so the latest release no longer generates a source file that then gets compiled into a binary, which rules_go expects it to do. Instead, a new package mode was added, which calls the go binary, which is unavailable in the Bazel sandbox.

I tried to modify rules_go to support the new mode but my bazel-fu isn't quite at the level needed for that 😄

Error

ERROR: xxx/BUILD.bazel:15:7: GoMockReflectProgOnlyGen xxx.go failed: (Exit 1): sandbox-exec failed: error executing GoMockReflectProgOnlyGen command
  (cd xxx/execroot/_main && \
  exec env - \
    TMPDIR=xxx/T/ \
  /usr/bin/sandbox-exec -f xxx/sandbox.sb xxx/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=xxx/stats.out' /bin/bash -c '
           $(pwd)/xxx/mockgen -prog_only xxx xxx > xxx.go
        ')
2024/10/23 13:49:53 Loading input failed: load package: load packages: err: go command required, not found: exec: "go": executable file not found in $PATH: stderr:
@fmeum
Copy link
Member

fmeum commented Oct 23, 2024

@linzhp

@linzhp
Copy link
Contributor

linzhp commented Oct 24, 2024

We are not planning to support Uber's gomock in rules_go. The plan is to move it to the same repo as Uber's gomock so they can co-evolve easily. The maintainers of Uber's gomock agreed with the plan. It's in my backlog, but any helping hand will be welcomed.

@SpencerC
Copy link

@linzhp, to clarify, is the plan to move gomock.bzl to the Uber gomock repo? Is this just as simple as creating a PR in the Uber gomock repo copying it over?

@linzhp
Copy link
Contributor

linzhp commented Nov 19, 2024

Yes, the first PR would be just that and maybe update the mockgen tool used by the rule to be Uber's mockgen. As followups, we should also

  • set up some tests to make sure gomock rule work as expected
  • publish the gomock rule to Bazel Central Registry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants