简体   繁体   中英

Error message:protoc-gen-go: Plugin failed with status code 1

This is not a duplicate question

First, I made sure I have the following configuration:

  1 export GOPATH=/Users/chezixin/go
  2 export GOBIN=/Users/chezixin/go/bin
  3 
  4 export GO111MODULE=on
  5 # 123
  6 export GOPROXY=https://goproxy.cn
  7 
  8 
  9 export PATH="$PATH:/Applications/Postgres.app/Contents/Versions/12/bin:/Users/chezixin/flutterSDK/flutter/bin:/usr/local/go/bin:$GOPATH:$GOBIN"
 10


 czxmac:~ chezixin$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:
/sbin:/Applications/VMwareFusion.app/Contents/Public:
/Applications/Postgres.app/Contents/Versions/latest/bin:
/Applications/Postgres.app/Contents/Versions/12/bin:
/Users/chezixin/flutterSDK/flutter/bin:/usr/local/go/bin:
/Users/chezixin/go:/Users/chezixin/go/bin':
/Users/chezixin/Go/bin:/Applications/Postgres.app/Contents/Versions/12/bin:
/Users/chezixin/flutterSDK/flutter/bin:
/usr/local/go/bin:/Users/chezixin/go:
/Users/chezixin/go/bin:/Users/chezixin/Go/bin

Already installed: go get -u google.golang.org/grpc

look protoc:

czxmac:~ chezixin$ protoc --version
libprotoc 3.11.1

Protoc-gen-go is installed and exists in $ GOPATH/bin

go get -u github.com/golang/protobuf/protoc-gen-go

problem: When I execute the following command

$ protoc --go_out=plugins=grpc:. *.proto

An error occurred:

protoc-gen-go: 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_out: protoc-gen-go: Plugin failed with status code 1.

Where is the problem, please master guidance.

This issue is related with your PATH variable, please set it again. I can see a typo of an extra trailing apostrophe(') in this line of PATH variable. /Users/chezixin/go:/Users/chezixin/go/bin':

Try updating it to /Users/chezixin/go:/Users/chezixin/go/bin:

For anyone facing a similar issue, but it was not the case of an invalid PATH variable, I very much sympathize with you.

I realized that I had to install the compiler (again?) before it started working. I hadn't installed it before, but it appeared to already be downloaded. I guess I had to install it again or update it.

I personally was using betterproto , and I followed the instructions here to install it with the protoc plugin and try out their example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM