protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Generated files conflict with each other on different computers

Open pltr opened this issue 6 years ago • 6 comments

When generating go files, gogoproto seems to generate it differently depending on the version of protoc installed on a particular machine. Which causes a lot of problems when editing proto files as even a small edit ends up in a lot of

-func init() { proto.RegisterFile("foo.proto", fileDescriptor_foo_b018e233b5cfb1ea) }
+func init() { proto.RegisterFile("foo.proto", fileDescriptor_foo_2c2bda422249515b) }

everywhere. It's basically impossible to lock down anything like that. Is it possible to turn it off somehow?

pltr avatar Oct 31 '18 19:10 pltr

i've seen this before. check that your protoc version matches on each system

ilackarms avatar Nov 27 '18 21:11 ilackarms

Checking that all developers use the same version of protoc is not not very realistic honestly. Also not quite sure what the benefit of it is. The hash it generates being the only difference.

pltr avatar Nov 27 '18 22:11 pltr

Could you let us know if you get this problem with golang/protobuf?

donaldgraham avatar Dec 03 '18 13:12 donaldgraham

@donaldgraham no. This is how golang/protobuf generates that descriptor variable: https://github.com/golang/protobuf/blob/8d0c54c1246661d9a51ca0ba455d22116d485eaa/protoc-gen-go/generator/generator.go#L284

Basically just "fileDescriptor_" + hashOf(filename)

Whereas gogo involves some complicated magic scheme with descriptor fingerprinting: https://github.com/gogo/protobuf/blob/e5d5b02ea0b3c4fd2a996e909ffa0f3421d6c91b/protoc-gen-gogo/generator/generator.go#L319

pltr avatar Dec 04 '18 11:12 pltr

Thanks. That's useful information.

donaldgraham avatar Dec 04 '18 14:12 donaldgraham

i met the same problem.....Has anyone solved this problem yet😭😭

wenli7363 avatar Jul 30 '23 02:07 wenli7363