Error: protoc-gen-go-grpc: program not found or is not executable
The error message suggests that the program protoc-gen-go-grpc
either cannot be found or is not executable on your system. This program is part of the protoc
compiler suite and is used for generating gRPC code from protocol buffer definitions.
Possible causes:
- The
protoc-gen-go-grpc
program is not installed. - The program is installed but not added to the system’s executable path.
- The program is installed and added to the path, but lacks proper execution permissions.
Solution:
To resolve this issue, follow the steps below:
- Check if the program is installed by running the following command in your terminal or command prompt:
- If the program is not installed, install it using the appropriate installation method on your system. For example, using
go get
command: - If the program is installed, but not added to the system’s executable path, you can either add the path manually or use the full path when generating gRPC code. For example:
- If the program is installed, added to the path but lacks execution permissions, you need to grant the necessary permissions. For Unix-based systems, use the
chmod
command:
protoc-gen-go-grpc --version
If you see the version information, it means the program is installed. Otherwise, proceed to the next step.
go get google.golang.org/grpc/cmd/protoc-gen-go-grpc
protoc --go-grpc_out=. --go-grpc_opt=paths=source_relative --plugin=protoc-gen-go-grpc=/path/to/protoc-gen-go-grpc your_service.proto
Replace /path/to/protoc-gen-go-grpc
with the actual path to the protoc-gen-go-grpc
executable.
chmod +x /path/to/protoc-gen-go-grpc
Example:
Let’s assume you have a protobuf file named example.proto
and you want to generate gRPC code for Go. Make sure to replace /path/to/protoc-gen-go-grpc
with the actual path to your protoc-gen-go-grpc
program:
protoc --go-grpc_out=. --go-grpc_opt=paths=source_relative --plugin=protoc-gen-go-grpc=/path/to/protoc-gen-go-grpc example.proto
This command will generate Go code for gRPC based on the example.proto
file using the protoc-gen-go-grpc
program.