zero-doc icon indicating copy to clipboard operation
zero-doc copied to clipboard

mac m1 安装protoc报错

Open cjhlai opened this issue 2 years ago • 2 comments

wget https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-linux-x86_64.zip unzip protoc-3.14.0-linux-x86_64.zip mv bin/protoc /usr/local/bin/

mac 64位的电脑,按上述步骤安装完protoc 在执行 goctl rpc protoc transform.proto --go_out=./pb --go-grpc_out=./pb --zrpc_out=.后,报错:sh: /usr/local/bin/protoc: cannot execute binary file 看了下, /usr/local/bin/protoc文件确实有的 应该怎么源码安装呀

cjhlai avatar Sep 28 '22 02:09 cjhlai

M1 怎么能用x86_64编译的文件呢 如果不是在liunx虚拟机里面应该切换到osx才可以

Peanut-5 avatar Nov 02 '22 09:11 Peanut-5

I had the same problem running protoc binaries. I followed this link: https://stackoverflow.com/questions/57700860/error-protoc-gen-go-program-not-found-or-is-not-executable

First install the Protocol Buffer Compiler Installation. Run: $ brew install protobuf

Then execute: $ go install google.golang.org/protobuf/cmd/protoc-gen-go@latest $ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

Go install directs binaries to $GOPATH/bin/. Add this to your path variable to be able to execute the proper binaries. I did this by adding the following to my ~/.zshrc file:

export GOROOT=/usr/local/go export GOPATH=$HOME/go export GOBIN=$GOPATH/bin export PATH=$PATH:$GOROOT:$GOPATH:$GOBIN

svott03 avatar Dec 28 '22 03:12 svott03