buf generate "unable to find protoc plugin" in CI
For local plugins, buf generate runs a binary named protoc-gen-<name> from PATH. When buf.gen.yaml names a plugin whose binary is not installed on the runner, buf reports it cannot find the plugin and aborts.
What this error means
buf generate fails with "unable to find protoc plugin for name \"go\"" or "could not find protoc plugin \"protoc-gen-connect-go\"" before any code is written.
Failure: plugin go: unable to find protoc plugin for name "go": exec: "protoc-gen-go": executable file not found in $PATHCommon causes
The local plugin binary is not installed
buf.gen.yaml uses plugin: go (a local plugin), but protoc-gen-go was never installed on the runner.
Installed but GOPATH/bin not on PATH
The plugin exists under $(go env GOPATH)/bin, which the buf generate step does not have on PATH.
How to fix it
Install the named plugins and expose PATH
- Install each
protoc-gen-<name>referenced in buf.gen.yaml. - Add
$(go env GOPATH)/binto PATH for the generate step. - Re-run
buf generate.
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
buf generateUse remote plugins to avoid local installs
Reference plugins hosted on the Buf Schema Registry so no local binary is required on the runner.
# buf.gen.yaml
version: v1
plugins:
- plugin: buf.build/protocolbuffers/go
out: gen/go
opt: paths=source_relativeHow to prevent it
- Install all local codegen plugins before
buf generate. - Add
$(go env GOPATH)/binto GITHUB_PATH in setup. - Prefer remote plugins so CI needs no local plugin binaries.