How to Fix protoc-gen-go-grpc: program not found or is not executable

To fix the protoc-gen-go-grpc: program not found or is not executable error in Golang, “install the protoc-gen-go-grpc” plugin using this command: go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest. This command will download and install the protoc-gen-go-grpc plugin into your GOBIN or GOPATH/bin directory.

Go raises the error “protoc-gen-go-grpc: program not found or is not executable” when the protoc compiler cannot find the protoc-gen-go-grpc plugin in your system’s PATH. This plugin is required to generate gRPC code for using Protocol Buffers.

Add the plugin to your system’s PATH

Ensure that your GOBIN or GOPATH/bin directory is added to your system’s PATH environment variable. This allows the protoc compiler to find and use the protoc-gen-go-grpc plugin.

For example, you can add the following line to your ~/.bashrc, ~/.bash_profile, or ~/.zshrc file (depending on your shell):

export PATH=$PATH:$(go env GOPATH)/bin

After adding this line, restart your terminal or run source ~/.bashrc, source ~/.bash_profile, or source ~/.zshrc to apply the changes.

Now the protoc compiler should be able to find and use the protoc-gen-go-grpc plugin when generating the gRPC code for Go.

That’s it.

Leave a Comment