Skip to content

protoc-gen-go: regression in handling of source_relative parameter #1076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kevinburke1 opened this issue Apr 12, 2020 · 6 comments
Closed

Comments

@kevinburke1
Copy link

kevinburke1 commented Apr 12, 2020

I am attempting to generate a Go pb.go file. This is the command I am running to generate it with the old binary:

cd pb && protoc --ruby_out=source_relative:../ruby/pb --go_out=source_relative:/Users/kevin/src api.proto

I run that command from $GOPATH/src/github.com/myorg/myproject. It writes a file to $GOPATH/src/github.com/myorg/myproject/pb/api.pb.go.

With the new cmd/protoc-gen-go, I get the following error:

cd pb && protoc --ruby_out=source_relative:../ruby/pb --go_out=source_relative:/Users/kevin/src api.proto
protoc-gen-go: no such flag -source_relative
--go_out: protoc-gen-go: Plugin failed with status code 1.
make: *** [Makefile:13: pb/api.pb.go] Error 1

Confusingly, I can see references to source_relative in the source code, but the references in the README of the new project have disappeared.

I can get it to generate a file by changing the command to read:

cd pb && protoc --ruby_out=source_relative:../ruby/pb --go_out=paths=source_relative:/Users/kevin/src api.proto

However, this writes api.pb.go to $GOPATH/src/api.pb.go, not $GOPATH/src/github.com/myorg/myproject/pb/api.pb.go as I expect.

@kevinburke1
Copy link
Author

I should add, I have this in api.proto

option go_package = "github.com/myorg/myproject/pb";

@dsnet
Copy link
Member

dsnet commented Apr 12, 2020

It is a surprise to me that --go_out=source_relative:output_dir worked. If it did, that was actually a bug in the old implementation and was not the intention of how the flag worked. The documentation for source_relative says it should actually be like: --go_out=paths=source_relative:output_dir.

\cc @neild to decide whether we should forward port this "feature" to the new implementation.

@dsnet dsnet changed the title regression in handling of source_relative parameter protoc-gen-go: regression in handling of source_relative parameter Apr 12, 2020
@neild
Copy link
Contributor

neild commented Apr 12, 2020

I don't understand how --go_out=source_relative:output_dir could ever have worked. The only reference to source_relative in the source code only applies to a paths=source_relative parameter:

https://github.com/golang/protobuf/blob/master/protoc-gen-go/generator/generator.go#L488

@neild
Copy link
Contributor

neild commented Apr 12, 2020

Also, so far as I can tell, the Ruby code generator has no support for a source_relative option. I don't see one anywhere: https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/compiler/ruby/ruby_generator.cc

@kevinburke1
Copy link
Author

Ah, doing some more experiments, with the old generator I get the same results if I remove source_relative:, so it just reads --go_out=/Users/kevin/src.

I believe it took a large amount of tinkering to get the outputs the way I wanted so I probably stopped once I got it working.

@kevinburke1
Copy link
Author

I think this should be closed, tightening argument parsing so things that had no effect, and should not have been allowed, are now not allowed, doesn't seem like a regression. My mistake was in assuming that this was doing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants