go build_error ai_generated true

protoc-gen-go: program not found or is not executable

ID: go/protoc-gen-go-missing-plugin

Also available as: JSON · Markdown · 中文
80%Fix Rate
89%Confidence
0Evidence
2024-01-08First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
google.golang.org/protobuf v1.28+ active

Root Cause

protoc cannot locate the protoc-gen-go plugin binary on PATH. It is installed via go install but $GOPATH/bin is not on PATH, or the binary name is wrong.

generic

中文

protoc 在 PATH 上找不到 protoc-gen-go 插件二进制。它通过 go install 安装,但 $GOPATH/bin 未加入 PATH,或二进制名称不对。

Workarounds

  1. 95% success
    go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
    export PATH="$PATH:$(go env GOPATH)/bin"
    which protoc-gen-go
  2. 90% success
    protoc --plugin=protoc-gen-go=$(go env GOPATH)/bin/protoc-gen-go \
      --go_out=. user.proto

Dead Ends

Common approaches that don't work:

  1. 80% fail

    The error is about the Go plugin, not the protoc compiler. Reinstalling protoc does not add protoc-gen-go to PATH.

  2. 75% fail

    protoc resolves plugins by name on PATH; passing a binary path as an output directory is invalid.