Hardik Jethava
Hardik Jethava

Reputation: 63

Getting "protoc": executable file not found in $PATH when running "go generate" command

We have an application written in GoLang and we are using GRPC for defining service contracts.

When we try to run "go generate" command to generate stub from proto file it gives following error:

main.go:4: running "protoc": exec: "protoc": executable file not found in $PATH

Command format in code:

//go:generate protoc -I . --go-grpc_out=. --go_out=.  ./proto/service.proto

Note:

Upvotes: 5

Views: 12055

Answers (2)

Praveen Kumar S
Praveen Kumar S

Reputation: 31

Installing protobuf-complier woker for me.

yum install protobuf-compiler

Upvotes: 0

rustyx
rustyx

Reputation: 85531

protoc-gen-go and protoc-gen-go-grpc are plugins for protoc. You need to install the protoc (the Protobuf compiler) itself, as explained in Go gRPC - Prerequisites.

See protobuf - Releases page for a download.

On a Mac can just use brew install protobuf.

Upvotes: 5

Related Questions