Skip to content

go-protoc-bin failed: error executing GoProtocGen command #4317

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

Closed
johanbrandhorst opened this issue Apr 15, 2025 · 9 comments · Fixed by #4324
Closed

go-protoc-bin failed: error executing GoProtocGen command #4317

johanbrandhorst opened this issue Apr 15, 2025 · 9 comments · Fixed by #4324

Comments

@johanbrandhorst
Copy link
Contributor

Hi! I'm the maintainer of the grpc-gateway. It seems that something in v0.54.0 broke our protobuf generation. This auto-created PR is failing our bazel build. The error is:

 ERROR: /__w/grpc-gateway/grpc-gateway/runtime/internal/examplepb/BUILD.bazel:29:17: Generating into bazel-out/k8-fastbuild/bin/runtime/internal/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb failed: (Exit 1): go-protoc-bin failed: error executing GoProtocGen command (from target //runtime/internal/examplepb:examplepb_go_proto) bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/rules_go+/go/tools/builders/go-protoc/go-protoc-bin -protoc bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/protobuf+/protoc -importpath ... (remaining 51 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
2025/04/15 16:46:48 file "bazel-out/k8-fastbuild/bin/runtime/internal/examplepb/examplepb_go_proto_/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb/example_grpc.pb.go" expected from plugin "bazel-out/k8-opt-exec-ST-d57f47055a04/bin/go_grpc_reset_plugin_/protoc-gen-go-grpc" but not created
ERROR: /__w/grpc-gateway/grpc-gateway/runtime/internal/examplepb/BUILD.bazel:29:17 GoCompilePkg runtime/internal/examplepb/examplepb_go_proto.a failed: (Exit 1): go-protoc-bin failed: error executing GoProtocGen command (from target //runtime/internal/examplepb:examplepb_go_proto) bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/rules_go+/go/tools/builders/go-protoc/go-protoc-bin -protoc bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/protobuf+/protoc -importpath ... (remaining 51 arguments skipped)

I found this a bit hard to parse, but I think the salient part is

go-protoc-bin failed: error executing GoProtocGen command

It doesn't say what exactly failed, though, so not sure how it broke. Here's the full build log: https://github.com/grpc-ecosystem/grpc-gateway/actions/runs/14474740731/job/40597503943?pr=5472. The command was

$ bazel test //...
@fmeum
Copy link
Member

fmeum commented Apr 15, 2025

We recently made it an error if a proto plugin fails to create files it claims to create to also masking errors. I don't know of any other changes.

@johanbrandhorst
Copy link
Contributor Author

Thanks, I'll try and investigate if that is happening in my case.

@ptxmac
Copy link

ptxmac commented Apr 16, 2025

We're seeing a similar issue. I can't post the complete code, but here's a snippet:

go_proto_library(
    name = "some_lib",
    compilers = [
        "//bazel/rules/protobuf/go:go_proto",
        "//bazel/rules/protobuf/go:go_grpc_v2",
    ],
    importpath = "some/custom/import/proto_library",
    protos = [
        "//another/path:common_proto",
        "//another/path:proto_library",
    ],
    deps = [
<  ... snip>
    ],
)

On 0.53.0 this correctly creates:

    ├── common.pb.go
    ├── common_grpc.pb.go
    ├── our_api.pb.go
    └── our_api_grpc.pb.go

But after upgrading to 0.54.0 the _grpc.go files are no longer created

We have other targets that DO work, but this one has a importpath that's different from where the BUILD.bazel file is, so that might be related.

@ptxmac
Copy link

ptxmac commented Apr 16, 2025

After some investigation, I discovered the problem:

  • The previous rules_go created a dummy file
  • one of the two protos in the target did not have a service, so the grpc compiler created no output

I'm not sure what the solution is, the first proto needs to be compiled with the grpc compiler, and it depends on the 2nd proto. But the change in 0.54.0 requires all compilers to create output for all files

@ptxmac
Copy link

ptxmac commented May 13, 2025

Any plans to create a 0.54.1 release with this fix?

@linzhp
Copy link
Contributor

linzhp commented May 13, 2025

yeah, I can create one later this week

@guw
Copy link

guw commented May 19, 2025

@linzhp @fmeum BCR still hast 0.54.0. Can a fix be published? 🙏

For cross-linking: connectrpc/connect-go#846

linzhp added a commit that referenced this issue May 20, 2025
…4324)

**What type of PR is this?**
Bug fix


**What does this PR do? Why is it needed?**
It's common for a `go_proto_library` to include proto files with and
without service definitions at the same time. In this case, the gRPC
plugins are needed, but some gRPC plugins don't generate the grpc.pb.go
files if there is no service definition.

Partially reverting #4287 to restore the previous behavior of creating
an empty file

**Which issues(s) does this PR fix?**

Fixes #4317

**Other notes for review**

---------

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
@linzhp
Copy link
Contributor

linzhp commented May 20, 2025

Publishing: bazelbuild/bazel-central-registry#4626

Sorry for the delay

@johanbrandhorst
Copy link
Contributor Author

Fixed my workflow, thank you! grpc-ecosystem/grpc-gateway#5594

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

Successfully merging a pull request may close this issue.

5 participants