Skip to content

gogo.proto: File not found.

Problem

When i run make command in gogo/protobuf (v1.3.2), get the errors as follows:

protoc --gogo_out=. --proto_path=../protobuf/:../:../../../../:. thetest.proto
github.com/gogo/protobuf/gogoproto/gogo.proto: File not found.

Solution

refer to gogo-proto-file-not-found on stackoverflow . Followed the answer in the article, but still the same error .

There is a open issue for this problem

Then I have a question, “How it passed the tests of its travis ci?”

I run the ./install-protobuf.sh

+ cd /home/daomin
+ case "$PROTOBUF_VERSION" in
+ die 'unknown protobuf version: '
+ echo 'unknown protobuf version: '
unknown protobuf version: 
+ exit 1

I need the protobuf version in my local machine. So I run protoc --version

libprotoc 3.12.4

Then I set the $PROTOBUF_VERSION by export PROTOBUF_VERSION=3.12.4

Run ./install-protobuf.sh again, then everything seems good

+ cd /home/daomin
+ case "$PROTOBUF_VERSION" in
+ basename=protoc-3.12.4-linux-x86_64
+ wget https://github.com/google/protobuf/releases/download/v3.12.4/protoc-3.12.4-linux-x86_64.zip
--2021-11-04 22:53:20--  https://github.com/google/protobuf/releases/download/v3.12.4/protoc-3.12.4-linux-x86_64.zip
Resolving github.com (github.com)... 20.205.243.166
Connecting to github.com (github.com)|20.205.243.166|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://github.com/protocolbuffers/protobuf/releases/download/v3.12.4/protoc-3.12.4-linux-x86_64.zip [following]
--2021-11-04 22:53:20--  https://github.com/protocolbuffers/protobuf/releases/download/v3.12.4/protoc-3.12.4-linux-x86_64.zip
Reusing existing connection to github.com:443.
HTTP request sent, awaiting response... 302 Found
Location: https://github-releases.githubusercontent.com/23357588/64809480-d0f3-11ea-81ae-a2ca95885a90?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211104%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211104T145321Z&X-Amz-Expires=300&X-Amz-Signature=41fde597f4224aeb508f08c0c22704c186296b1ee2e6f403816a976d14398955&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=23357588&response-content-disposition=attachment%3B%20filename%3Dprotoc-3.12.4-linux-x86_64.zip&response-content-type=application%2Foctet-stream [following]
--2021-11-04 22:53:21--  https://github-releases.githubusercontent.com/23357588/64809480-d0f3-11ea-81ae-a2ca95885a90?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211104%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211104T145321Z&X-Amz-Expires=300&X-Amz-Signature=41fde597f4224aeb508f08c0c22704c186296b1ee2e6f403816a976d14398955&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=23357588&response-content-disposition=attachment%3B%20filename%3Dprotoc-3.12.4-linux-x86_64.zip&response-content-type=application%2Foctet-stream
Resolving github-releases.githubusercontent.com (github-releases.githubusercontent.com)... 185.199.110.154, 185.199.109.154, 185.199.108.154, ...
Connecting to github-releases.githubusercontent.com (github-releases.githubusercontent.com)|185.199.110.154|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1609197 (1.5M) [application/octet-stream]
Saving to: ‘protoc-3.12.4-linux-x86_64.zip.3’

protoc-3.12.4-linux-x86_64.zip.3                            100%[==========================================================================================================================================>]   1.53M  9.24MB/s    in 0.2s    

2021-11-04 22:53:21 (9.24 MB/s) - ‘protoc-3.12.4-linux-x86_64.zip.3’ saved [1609197/1609197]

+ unzip protoc-3.12.4-linux-x86_64.zip
Archive:  protoc-3.12.4-linux-x86_64.zip
replace include/google/protobuf/wrappers.proto? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
  inflating: include/google/protobuf/wrappers.proto  
  inflating: include/google/protobuf/field_mask.proto  
  inflating: include/google/protobuf/api.proto  
  inflating: include/google/protobuf/struct.proto  
  inflating: include/google/protobuf/descriptor.proto  
  inflating: include/google/protobuf/timestamp.proto  
  inflating: include/google/protobuf/compiler/plugin.proto  
  inflating: include/google/protobuf/empty.proto  
  inflating: include/google/protobuf/any.proto  
  inflating: include/google/protobuf/source_context.proto  
  inflating: include/google/protobuf/type.proto  
  inflating: include/google/protobuf/duration.proto  
  inflating: bin/protoc              
  inflating: readme.txt  

Now run make, still get the same Not Found error.

protoc --gogo_out=. --proto_path=../protobuf/:../:../../../../:. thetest.proto
github.com/gogo/protobuf/gogoproto/gogo.proto: File not found.

Follow the issue, export GO111MODULE=off, run make

go clean ./...
go install ./proto
go install ./gogoproto
gogoproto/gogo.pb.go:8:2: cannot find package "github.com/gogo/protobuf/proto" in any of:
	/home/daomin/.gvm/gos/go1.16/src/github.com/gogo/protobuf/proto (from $GOROOT)
	/home/daomin/.gvm/pkgsets/go1.16/global/src/github.com/gogo/protobuf/proto (from $GOPATH)
gogoproto/gogo.pb.go:9:2: cannot find package "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" in any of:
	/home/daomin/.gvm/gos/go1.16/src/github.com/gogo/protobuf/protoc-gen-gogo/descriptor (from $GOROOT)
	/home/daomin/.gvm/pkgsets/go1.16/global/src/github.com/gogo/protobuf/protoc-gen-gogo/descriptor (from $GOPATH)
make: *** [Makefile:45: install] Error 1

Follow the issue, go get github.com/gogo/protobuf

package github.com/gogo/protobuf: no Go files in /home/daomin/.gvm/pkgsets/go1.16/global/src/github.com/gogo/protobuf

make again

go clean ./...
go install ./proto
go install ./gogoproto
go install ./jsonpb
go install ./protoc-gen-gogo
go install: no install location for directory /home/daomin/projects/tmp/protobuf/protoc-gen-gogo outside GOPATH
	For more details see: 'go help gopath'
make: *** [Makefile:47: install] Error 1

Refer to https://stackoverflow.com/questions/18149601/go-install-fails-with-error-no-install-location-for-directory-xxx-outside-gopat, I change workspace to /home/daomin/.gvm/pkgsets/go1.16/global/src/github.com/gogo/protobuf, then make again. Then everything looks well.

I can start to test the lib at different versions of golang now .

Published ingolang问题处理

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *