i am getting this error when i compile my proto file:
protoc-gen-go-grpc: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
\--go-grpc_out: protoc-gen-go-grpc: Plugin failed with status code 1.
I am using these versions:
Binary | Version |
---|---|
protoc-gen-go | v1.25.0-devel |
protoc | v3.12.4 |
I have tried to compile this proto file:
syntax = "proto3";
option go_package = "proto/";
message GreetingRequest {
string first_name = 1;
string last_name = 2;
}
message GreetingResponse{
string result = 1;
}
service AddService{
rpc Greet(GreetingRequest) returns (GreetingResponse) {};
}
I used this command:
protoc \
--proto_path=proto \
--go_out=proto \
--go_opt=paths=source_relative \
--go-grpc_out=proto \
--go-grpc_opt=paths=source_relative \
service.proto
I installed protoc-gen-go-grpc
using:
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
but its still showing this error.
which protoc-gen-go-grpc
to determine where (in your path), the binary can be found. I suspect, it won't be found and you'll need to add it's location to yourPATH
– Emerald${GOPATH}/bin
. You may not haveGOPATH
(and I think there's aGOBIN
) too. – Emeraldprotoc
, it looks for plugins (other binaries) in thePATH
on your system. In your case, there are 2 plugins that are used.--go_*
is matched to a binaryprotoc-gen-go
and--go-grpc_*
is matched to a binaryprotoc-gen-go-grpc
. The flags are used to determine the binary's nameprotoc-gen-[[FLAG]]
. You just need to ensure that both those binaries are in thePATH
so thatprotoc
can find them when you run it. – EmeraldPATH
to include whatever paths you're using so thatprotoc
can findprotoc-gen-go
andprotoc-gen-go-gprc
in thePATH
. If these are in different locations both folders need to be in thePATH
. – Emeraldprotoc-gen-go-grpc
in the terminal using:PATH="/myDirectory:$PATH"
. Now the problem is how to set this path permanently? – Adrenocorticotropic