Dep: undefined: proto.ProtoPackageIsVersion3

Created on 8 Jan 2019  ยท  4Comments  ยท  Source: golang/dep


I am learning to implement microservices in go from @EwanValentine website, and as such Dockerizing a set of go apps that are supposed to work like microservices connected to each other (2 at the moment). So here's my Dockerfile content:

FROM golang:1.9.0 as builder

WORKDIR /go/src/gotut/consignment-service
COPY . .

RUN go get -v -u github.com/golang/dep/cmd/dep
RUN dep init -v && dep ensure -v
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo .

FROM alpine:latest
RUN apk --no-cache add ca-certificates

RUN mkdir /app
WORKDIR /app

COPY --from=builder /go/src/gotut/consignment-service .
CMD ["./consignment-service"]

In the line that I'm trying to run cgo, I confront the following error. I'm not sure if it's a dep error or not, but it felt like a starting point to figure it out anyway.

Step 5/12 : RUN dep init -v && dep ensure -v    
 ---> Running in c3361714bf17                             
Getting direct dependencies...                                                
Checked 3 directories for packages.                 
Found 3 direct dependencies.                                  
Root project is "gotut/consignment-service"                                    
 2 transitively valid internal packages              
 5 external packages imported from 3 projects                  
(0)   โœ“ select (root)                                                            
(1)     ? attempt golang.org/x/net with 1 pkgs; 7 versions to try
(1)         try golang.org/x/net@master                          
(1)     โœ“ select golang.org/x/net@master w/1 pkgs                                     
(2)     ? attempt github.com/micro/go-micro with 3 pkgs; 24 versions to try
(2)         try github.com/micro/[email protected]                                       
(2)     โœ“ select github.com/micro/[email protected] w/27 pkgs                  
(3)     ? revisit golang.org/x/net to add 1 pkgs                     
(3)       โœ“ include 4 more pkgs from golang.org/x/net@master                    
(3)     ? attempt github.com/micro/go-log with 1 pkgs; 1 versions to try           
(4)         try github.com/micro/go-log@master                        
(4)     โœ“ select github.com/micro/go-log@master w/1 pkgs                   
(4)     ? attempt github.com/micro/cli with 1 pkgs; 1 versions to try       
(5)         try github.com/micro/cli@master                           
(5)     โœ“ select github.com/micro/cli@master w/1 pkgs                                                                       
(5)     ? attempt github.com/micro/h2c with 1 pkgs; 2 versions to try             
(6)         try github.com/micro/[email protected]                                              
(6)     โœ“ select github.com/micro/[email protected] w/1 pkgs       
(6)     ? revisit golang.org/x/net to add 2 pkgs                
(7)       โœ“ include 3 more pkgs from golang.org/x/net@master            
(6)     ? attempt github.com/micro/util with 3 pkgs; 1 versions to try      
(8)         try github.com/micro/util@master                                
(8)     โœ“ select github.com/micro/util@master w/3 pkgs                                   
(7)     ? attempt github.com/micro/go-rcache with 1 pkgs; 1 versions to try             
(9)         try github.com/micro/go-rcache@master                                                 
(9)     โœ“ select github.com/micro/go-rcache@master w/1 pkgs                              
(8)     ? revisit github.com/micro/go-micro to add 1 pkgs                               
(10)    โœ“ include 1 more pkgs from github.com/micro/[email protected]                              
(8)     ? attempt github.com/go-log/log with 2 pkgs; 2 versions to try     
(11)      try github.com/go-log/[email protected]                          
(11)  โœ“ select github.com/go-log/[email protected] w/2 pkgs                            
(9)     ? attempt github.com/mitchellh/hashstructure with 1 pkgs; 2 versions to try
(12)      try github.com/mitchellh/[email protected]                         
(12)  โœ“ select github.com/mitchellh/[email protected] w/1 pkgs                                                           
(10)  ? attempt github.com/micro/mdns with 1 pkgs; 1 versions to try                      
(13)      try github.com/micro/mdns@master                          
(13)  โœ“ select github.com/micro/mdns@master w/1 pkgs
(11)  ? revisit golang.org/x/net to add 2 pkgs     
(14)    โœ“ include 5 more pkgs from golang.org/x/net@master                    
(11)  ? attempt github.com/google/uuid with 1 pkgs; 10 versions to try
(15)      try github.com/google/[email protected]                   
(15)  โœ“ select github.com/google/[email protected] w/1 pkgs             
(12)  ? attempt golang.org/x/text with 3 pkgs; 5 versions to try
(16)      try golang.org/x/[email protected]            
(16)  โœ“ select golang.org/x/[email protected] w/14 pkgs              
(13)  ? attempt github.com/golang/protobuf with 1 pkgs; 8 versions to try
(17)      try github.com/golang/[email protected]
(17)  โœ“ select github.com/golang/[email protected] w/1 pkgs
(14)  ? attempt github.com/hashicorp/memberlist with 1 pkgs; 3 versions to try
(18)      try github.com/hashicorp/[email protected]
(18)  โœ“ select github.com/hashicorp/[email protected] w/1 pkgs
(15)  ? attempt github.com/armon/go-metrics with 1 pkgs; 1 versions to try
(19)      try github.com/armon/go-metrics@master
(19)  โœ“ select github.com/armon/go-metrics@master w/1 pkgs
(16)  ? attempt github.com/hashicorp/go-msgpack with 1 pkgs; 1 versions to try
(20)      try github.com/hashicorp/go-msgpack@master
(20)  โœ“ select github.com/hashicorp/go-msgpack@master w/1 pkgs
(17)  ? attempt github.com/hashicorp/go-sockaddr with 1 pkgs; 1 versions to try
(21)      try github.com/hashicorp/go-sockaddr@master
(21)  โœ“ select github.com/hashicorp/go-sockaddr@master w/1 pkgs
(18)  ? attempt github.com/hashicorp/go-multierror with 1 pkgs; 2 versions to try
(22)      try github.com/hashicorp/[email protected]          
(22)  โœ“ select github.com/hashicorp/[email protected] w/1 pkgs
(19)  ? attempt github.com/hashicorp/go-immutable-radix with 1 pkgs; 3 versions to try
(23)      try github.com/hashicorp/[email protected]               
(23)  โœ“ select github.com/hashicorp/[email protected] w/1 pkgs                  
(20)  ? attempt github.com/hashicorp/golang-lru with 1 pkgs; 3 versions to try
(24)      try github.com/hashicorp/[email protected]                 
(24)  โœ“ select github.com/hashicorp/[email protected] w/1 pkgs                  
(21)  ? attempt github.com/sean-/seed with 1 pkgs; 1 versions to try               
(25)      try github.com/sean-/seed@master                            
(25)  โœ“ select github.com/sean-/seed@master w/1 pkgs                       
(22)  ? attempt github.com/hashicorp/consul with 2 pkgs; 137 versions to try
(26)      try github.com/hashicorp/[email protected]                      
Importing configuration from govendor. These are only initial constraints, and are further refined during the solve process.
(26)  โœ“ select github.com/hashicorp/[email protected] w/2 pkgs                        
(23)  ? attempt github.com/hashicorp/go-rootcerts with 1 pkgs; at least 1 versions to try
(27)      try github.com/hashicorp/go-rootcerts@master      
(27)  โœ“ select github.com/hashicorp/go-rootcerts@master w/1 pkgs
(24)  ? attempt github.com/pkg/errors with 1 pkgs; 13 versions to try   
(28)      try github.com/pkg/[email protected]                                  
(28)  โœ“ select github.com/pkg/[email protected] w/1 pkgs                        
(25)  ? attempt github.com/mitchellh/mapstructure with 1 pkgs; at least 1 versions to try
(29)      try github.com/mitchellh/mapstructure@5a380f224700b8a6c4eaad048804f5bff514cb35
(29)  โœ“ select github.com/mitchellh/mapstructure@5a380f224700b8a6c4eaad048804f5bff514cb35 w/1 pkgs
(26)  ? attempt github.com/hashicorp/go-cleanhttp with 1 pkgs; at least 1 versions to try
(30)      try github.com/hashicorp/go-cleanhttp@d5fe4b57a186c716b0e00b8c301cbd9b4182694d
(30)  โœ“ select github.com/hashicorp/go-cleanhttp@d5fe4b57a186c716b0e00b8c301cbd9b4182694d w/1 pkgs
(27)  ? attempt github.com/hashicorp/errwrap with 1 pkgs; 2 versions to try
(31)      try github.com/hashicorp/[email protected]                   
(31)  โœ“ select github.com/hashicorp/[email protected] w/1 pkgs                     
(28)  ? attempt github.com/hashicorp/serf with 1 pkgs; at least 1 versions to try  
(32)      try github.com/hashicorp/serf@19bbd39e421bdf3559d5025fb2c760f5ffa56233
Importing configuration from govendor. These are only initial constraints, and are further refined during the solve process.
(32)  โœ“ select github.com/hashicorp/serf@19bbd39e421bdf3559d5025fb2c760f5ffa56233 w/1 pkgs
(29)  ? attempt github.com/miekg/dns with 1 pkgs; 20 versions to try
(33)      try github.com/miekg/[email protected]           
(33)  โœ“ select github.com/miekg/[email protected] w/1 pkgs
(30)  ? attempt github.com/mitchellh/go-homedir with 1 pkgs; 2 versions to try
(34)      try github.com/mitchellh/[email protected]                  
(34)  โœ“ select github.com/mitchellh/[email protected] w/1 pkgs
(31)  ? attempt golang.org/x/crypto with 1 pkgs; 2 versions to try
(35)      try golang.org/x/crypto@master                        
(35)  โœ“ select golang.org/x/crypto@master w/2 pkgs
(32)  ? attempt golang.org/x/sys with 1 pkgs; 2 versions to try
(36)      try golang.org/x/sys@master                                    
(36)  โœ“ select golang.org/x/sys@master w/1 pkgs
  โœ“ found solution with 85 packages from 32 projects     

Solver wall times by segment:                       
     b-source-exists:  3m7.540708226s                         
              b-gmal: 2m14.796182132s                                     
     b-list-versions:   33.657612278s           
         b-list-pkgs:    3.812255246s                     
  b-deduce-proj-root:    224.398336ms                                         
         select-atom:     30.496254ms               
             satisfy:     22.831466ms                         
            new-atom:      1.406066ms                                          
            add-atom:       465.561ยตs                
               other:       190.386ยตs                          
         select-root:       176.794ยตs                                            

  TOTAL: 6m0.086722745s                                          

  Locking in v0.3.0 (f21a4df) for transitive dep golang.org/x/text         
  Locking in v1.0.0 (27df809) for transitive dep github.com/hashicorp/go-immutable-radix
  Locking in  (5a380f2) for transitive dep github.com/mitchellh/mapstructure  
  Locking in v1.1.2 (44a8c5f) for transitive dep github.com/miekg/dns
  Locking in v0.1.0 (ce8abaa) for transitive dep github.com/hashicorp/memberlist
  Locking in v1.0.0 (886a7fb) for transitive dep github.com/hashicorp/go-multierror
  Locking in v0.8.1 (ba968bf) for transitive dep github.com/pkg/errors
  Locking in master (a581a57) for transitive dep github.com/micro/go-rcache
  Locking in v1.1.0 (9b3b1e0) for transitive dep github.com/google/uuid     
  Using ^1.2.0 as constraint for direct dep github.com/golang/protobuf
  Locking in v1.2.0 (aa810b6) for direct dep github.com/golang/protobuf                                                     
  Locking in master (6bb64b3) for transitive dep github.com/hashicorp/go-rootcerts
  Locking in v1.0.0 (8a6fb52) for transitive dep github.com/hashicorp/errwrap            
  Using master as constraint for direct dep golang.org/x/net
  Locking in master (45ffb0c) for direct dep golang.org/x/net   
  Locking in master (cbfa944) for transitive dep github.com/micro/go-log
  Locking in v1.4.0 (0bddfa2) for transitive dep github.com/hashicorp/consul
  Locking in  (d5fe4b5) for transitive dep github.com/hashicorp/go-cleanhttp
  Using ^0.17.0 as constraint for direct dep github.com/micro/go-micro                   
  Locking in v0.17.0 (461df8d) for direct dep github.com/micro/go-micro                 
  Locking in v0.1.0 (37e2e1f) for transitive dep github.com/go-log/log                            
  Locking in v0.5.0 (20f1fb7) for transitive dep github.com/hashicorp/golang-lru         
  Locking in master (2d4f591) for transitive dep github.com/micro/util                  
  Locking in master (f0300d1) for transitive dep github.com/armon/go-metrics                      
  Locking in master (e2103e2) for transitive dep github.com/sean-/seed     
  Locking in  (19bbd39) for transitive dep github.com/hashicorp/serf
  Locking in v1.0.0 (ae18d6b) for transitive dep github.com/mitchellh/go-homedir
  Locking in master (ff983b9) for transitive dep golang.org/x/crypto               
  Locking in master (1b0c979) for transitive dep github.com/micro/cli           
  Locking in v1.0.0 (b2f7b8e) for transitive dep github.com/micro/h2c                                                       
  Locking in master (9c3770d) for transitive dep github.com/micro/mdns                    
  Locking in master (20be8e5) for transitive dep golang.org/x/sys   
  Locking in v1.0.0 (a38c501) for transitive dep github.com/mitchellh/hashstructure
  Locking in master (fa3f638) for transitive dep github.com/hashicorp/go-msgpack
  Locking in master (e92cdb5) for transitive dep github.com/hashicorp/go-sockaddr
(1/32) Wrote github.com/micro/go-rcache@master                        
(2/32) Wrote github.com/hashicorp/[email protected]        
(3/32) Wrote github.com/pkg/[email protected]                         
(4/32) Wrote github.com/google/[email protected]                      
(5/32) Wrote github.com/hashicorp/go-cleanhttp@d5fe4b57a186c716b0e00b8c301cbd9b4182694d
(6/32) Wrote github.com/micro/go-log@master                    
(7/32) Wrote github.com/hashicorp/[email protected]                      
(8/32) Wrote github.com/hashicorp/[email protected]
(9/32) Wrote github.com/hashicorp/go-rootcerts@master    
(10/32) Wrote github.com/golang/[email protected]                               
(11/32) Wrote github.com/hashicorp/[email protected]
(12/32) Wrote github.com/mitchellh/[email protected]          
(13/32) Wrote github.com/sean-/seed@master                                
(14/32) Wrote github.com/armon/go-metrics@master
(15/32) Wrote github.com/micro/util@master                
(16/32) Wrote github.com/go-log/[email protected]                                    
(17/32) Wrote github.com/micro/mdns@master          
(18/32) Wrote github.com/hashicorp/go-sockaddr@master         
(19/32) Wrote github.com/mitchellh/mapstructure@5a380f224700b8a6c4eaad048804f5bff514cb35
(20/32) Wrote github.com/hashicorp/[email protected]    
(21/32) Wrote github.com/hashicorp/go-msgpack@master           
(22/32) Wrote github.com/micro/[email protected]                                  
(23/32) Wrote github.com/micro/[email protected]                        
(24/32) Wrote github.com/micro/cli@master                        
(25/32) Wrote github.com/mitchellh/[email protected]                               
(26/32) Wrote github.com/hashicorp/serf@19bbd39e421bdf3559d5025fb2c760f5ffa56233
(27/32) Wrote golang.org/x/net@master                                                   
(28/32) Wrote golang.org/x/crypto@master                                      
(29/32) Wrote golang.org/x/sys@master                                
(30/32) Wrote golang.org/x/[email protected]                                          
(31/32) Wrote github.com/miekg/[email protected]                                          
(32/32) Wrote github.com/hashicorp/[email protected]                      
Removing intermediate container c3361714bf17                               
 ---> 320e544f1713                                                          
Step 6/12 : RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo .
 ---> Running in 073a0f04451f                                                                                               
# gotut/consignment-service/vendor/github.com/micro/go-micro/registry/gossip/proto
vendor/github.com/micro/go-micro/registry/gossip/proto/gossip.pb.go:21:11: undefined: proto.ProtoPackageIsVersion3
# gotut/consignment-service/vendor/github.com/miekg/dns     
vendor/github.com/miekg/dns/dnssec_keyscan.go:295:7: undefined: strings.Builder
vendor/github.com/miekg/dns/msg_helpers.go:270:8: undefined: strings.Builder
vendor/github.com/miekg/dns/serve_mux.go:43:9: undefined: strings.Builder   
vendor/github.com/miekg/dns/types.go:432:10: undefined: strings.Builder     
vendor/github.com/miekg/dns/types.go:456:10: undefined: strings.Builder                  
vendor/github.com/miekg/dns/types.go:484:10: undefined: strings.Builder                 
vendor/github.com/miekg/dns/types.go:505:29: undefined: strings.Builder                           
vendor/github.com/miekg/dns/types.go:515:28: undefined: strings.Builder                  
# gotut/consignment-service/proto/consignment                                           
proto/consignment/consignment.pb.go:27:11: undefined: proto.ProtoPackageIsVersion3                
The command '/bin/sh -c CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo .' returned a non-zero code: 2
Makefile:6: recipe for target 'build' failed                        
make: *** [build] Error 2                                                       

thanks

What version of dep are you using (dep version)?


v0.5.0-15-g22125cfa

What dep command did you run?

dep init && dep ensure

Most helpful comment

You're also going to run into issues here:

vendor/github.com/miekg/dns/dnssec_keyscan.go:295:7: undefined: strings.Builder
vendor/github.com/miekg/dns/msg_helpers.go:270:8: undefined: strings.Builder
vendor/github.com/miekg/dns/serve_mux.go:43:9: undefined: strings.Builder 

strings.Builder was introduced in Go 1.10 IIRC, it's not available in Go 1.9. At the top of the Dockerfile you are using Go 1.9. Maybe try upgrading to Go 1.11.x to resolve the compile failure there.

All 4 comments

@meysam81 This comment might give some insight into solving your issue: https://github.com/golang/protobuf/issues/763#issuecomment-442767135 (You need to have the same version vendored as what is compiled into your protoc-gen-go)

You're also going to run into issues here:

vendor/github.com/miekg/dns/dnssec_keyscan.go:295:7: undefined: strings.Builder
vendor/github.com/miekg/dns/msg_helpers.go:270:8: undefined: strings.Builder
vendor/github.com/miekg/dns/serve_mux.go:43:9: undefined: strings.Builder 

strings.Builder was introduced in Go 1.10 IIRC, it's not available in Go 1.9. At the top of the Dockerfile you are using Go 1.9. Maybe try upgrading to Go 1.11.x to resolve the compile failure there.

@kevinburke Thanks man, it was helpful; and was a pain in the butt for some time.
The workaround was this:
from golang:latest as builder
Which has to be replaced in the beginning of the Dockerfile.

worked !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

avelino picture avelino  ยท  25Comments

wallrj picture wallrj  ยท  27Comments

bradleyfalzon picture bradleyfalzon  ยท  52Comments

sdboyer picture sdboyer  ยท  119Comments

sttts picture sttts  ยท  25Comments