Protobuf: protoc-gen-go: protoc fails to compile in Windows

Created on 2 Mar 2019  ·  12Comments  ·  Source: golang/protobuf

What version of protobuf and what language are you using?
Version: 1.3.0

What did you do?
I tried building a proto file using protoc. I have protoc-gen-go installed and %GOPATH%/bin in my PATH environment variable.

What did you expect to see?
A built .pb.go file.

What did you see instead?
an error message: The system cannot find the path specified. --go_out: protoc-gen-go: Plugin failed with status code 1.

here's the command i ran:
protoc -I %USERPROFILE%/Documents/Projects/go/gateway/protobuf --go_out=plugins=grpc:%GOPATH%/bin/protoc-gen-go %USERPROFILE%/Documents/Projects/go/gateway/protobuf/protobuf.proto

help-wanted

Most helpful comment

Try to install additional packages for Golang other than Go:
Golang packages:

go get -u github.com/golang/protobuf/protoc-gen-go
go get -u github.com/golang/protobuf/proto
you can run this from any directory and it will install packages to somewhere:
C:UsersDellgobin
Add this to PATH from Environment variables in Windows and then it will be OK

All 12 comments

Unfortunately, none of the core developers develop on windows, so we are unable to help directly. Marking this as "help-wanted" if someone in the community wants to help answer your question and/or fix protoc-gen-go to work on Windows.

I would expect your command-line should look something like: protoc -I %USERPROFILE%/Documents/Projects/go/gateway/protobuf --go_out=plugins=grpc:%OUTPUT_DIRECTORY% %USERPROFILE%/Documents/Projects/go/gateway/protobuf/protobuf.proto

Where %OUTPUT_DIRECTORY% is set to whatever is meaningful for your case (likely %USERPROFILE%/Documents/Projects/go/gateway/protobuf/)

I would much more preferably suggest that you run protoc from the directory directly rather than using complicated paths, that may contain spaces, or the : character, which one of the binaries might feasibly misunderstand. So: protoc -I protobuf/ --go_out=plugins=grpc:protobuf/ protobuf/protobuf.proto

In case it's useful information, I successfully ran the Go examples from the tutorials on Windows 10, Go 1.11.4, protoc 3.8.0-rc1, and the latest version of protoc-gen-go (1.3.1 as of this writing, I suppose) today.

same issue, using Windows Subsystem for Linux now.

It seems to me that this is a user-configuration error. If protoc can't find the protoc-gen-go binary, then somethings up with the PATH in Windows. I don't think there's anything actionable for us to do on our end.

Try to install additional packages for Golang other than Go:
Golang packages:

go get -u github.com/golang/protobuf/protoc-gen-go
go get -u github.com/golang/protobuf/proto
you can run this from any directory and it will install packages to somewhere:
C:UsersDellgobin
Add this to PATH from Environment variables in Windows and then it will be OK

We have the same problem now all of a sudden -- and we are using gradle (don't ask) to build with protoc-gen-go. Suddenly we have same issue on Windows on one particular build machine. I will figure it out, but would be nice to know that ".exe" is added to a plugin file name resolution on Windows anyway, even when it is invoked from cygwin

Alrighty... So found the culprit. Please don't laugh.

Gradle extracts protoc-gen-go plugin into some cache path, and it is quite long. As of today, together with file name itself it just crossed 256 path length.

I guess protoc 3.10 still cannot call a plugin sitting THAT(/s) deep in a path on Windows.

Welcome to 2020... 🤦‍♂

MAX_PATH we meet again. :squint:

go version go1.13 windows/amd64

➜  protobuf (master) go install -v ./...
github.com/golang/protobuf/protoc-gen-go/generator/internal/remap
github.com/golang/protobuf/protoc-gen-go/descriptor
github.com/golang/protobuf/ptypes/wrappers
github.com/golang/protobuf/proto/test_proto
github.com/golang/protobuf/ptypes/empty
github.com/golang/protobuf/jsonpb/jsonpb_test_proto
github.com/golang/protobuf/descriptor
github.com/golang/protobuf/protoc-gen-go/plugin
github.com/golang/protobuf/proto/proto3_proto
github.com/golang/protobuf/protoc-gen-go/generator
github.com/golang/protobuf/protoc-gen-go/grpc
github.com/golang/protobuf/protoc-gen-go
go install github.com/golang/protobuf/protoc-gen-go: mkdir D:\mygo\bin;C:: The filename, directory name, or volume label syntax is incorrect.

i'm on win10 and my issue was that after installing google.golang.org/grpc, which also installs github.com/golang/protobuf, protoc-gen-go.exe did not get build in GOPATH/bin. so running go get -u github.com/golang/protobuf/protoc-gen-go did the job and now protoc dir_name/whatever_name.proto --go_out=plugins=grpc:. does the job

I am tring to install protoc-gen-go in windows10 64bit. while run go get -u github.com/golang/protobuf/protoc-gen-go , getting following error

unrecognized import path "google.golang.org/protobuf/compiler/protogen
unrecognized import path "google.golang.org/protobuf/types/descriptorpb
unrecognized import path "google.golang.org/protobuf/cmd/protoc-gen-go/internal_gengo

what is the reason for this? pleas help me on this

sree

Was this page helpful?
0 / 5 - 0 ratings