Issue 315 in protobuf: erroneous duplicate definition error if imported file in subdirectory

2,035 views
Skip to first unread message

prot...@googlecode.com

unread,
Jul 15, 2011, 12:10:38 PM7/15/11
to prot...@googlegroups.com
Status: New
Owner: liuj...@google.com
Labels: Type-Defect Priority-Medium

New issue 315 by gerd94...@gmail.com: erroneous duplicate definition error
if imported file in subdirectory
http://code.google.com/p/protobuf/issues/detail?id=315

What steps will reproduce the problem?
Create "foo.proto" containing:
import "bar.proto";

Create "x/bar.proto" containing:
message bar {
optional int32 x = 1;
}

Try to compile:
protoc --python_out=. -I. -Ix foo.proto x/bar.proto

What is the expected output? What do you see instead?
Compilation shall succeed, just like it does if "x/bar.proto"
is "bar.proto" instead.
It also succeeds if "foo.proto" contains:
import "x/bar.proto"
instead.


What version of the product are you using? On what operating system?
2.3.0 and 2.4.1
Linux and MacOS

Please provide any additional information below.


Attachments:
foo.proto 20 bytes
bar.proto 40 bytes

prot...@googlecode.com

unread,
Jul 15, 2011, 12:14:40 PM7/15/11
to prot...@googlegroups.com

Comment #1 on issue 315 by gerd94...@gmail.com: erroneous duplicate
definition error if imported file in subdirectory
http://code.google.com/p/protobuf/issues/detail?id=315

The error message the compiler produces is:

% protoc --python_out=. -I. -Ix foo.proto
x/bar.proto
gerd@dhcp-171-71-136-245:~/tmp/x
x/bar.proto:2:18: "bar.x" is already defined in file "bar.proto".
x/bar.proto:1:9: "bar" is already defined in file "bar.proto".


prot...@googlecode.com

unread,
Dec 3, 2012, 5:41:58 PM12/3/12
to prot...@googlegroups.com
Updates:
Status: WorkingAsIntended

Comment #2 on issue 315 by xiaof...@google.com: erroneous duplicate
definition error if imported file in subdirectory
http://code.google.com/p/protobuf/issues/detail?id=315

To protocol compiler "bar.proto" and "x/bar.proto" are two proto files
although they are pointed at the same physical file.
Using 'import "x/bar.proto"' is the right fix.

prot...@googlecode.com

unread,
Dec 23, 2014, 5:19:43 AM12/23/14
to prot...@googlegroups.com

Comment #3 on issue 315 by Clear...@gmail.com: erroneous duplicate
definition error if imported file in subdirectory
https://code.google.com/p/protobuf/issues/detail?id=315

When I use protoc to generate /nested_extension.proto from source(version
2.5.0), I get the error message:
exec]
protobuf/java/src/test/java/com/google/protobuf/non_nested_extension.proto:39:9: "protobuf_unittest.MessageToBeExtended"
is already defined in file "com/google/protobuf/non_nested_extension.proto".
[exec]
protobuf/java/src/test/java/com/google/protobuf/non_nested_extension.proto:43:9: "protobuf_unittest.MyNonNestedExtension"
is already defined in file "com/google/protobuf/non_nested_extension.proto".
[exec]
protobuf/java/src/test/java/com/google/protobuf/non_nested_extension.proto:47:33: "protobuf_unittest.nonNestedExtension"
is already defined in file "com/google/protobuf/non_nested_extension.proto".
[exec]
protobuf/java/src/test/java/com/google/protobuf/non_nested_extension.proto:46:8: "protobuf_unittest.MessageToBeExtended"
seems to be defined in "com/google/protobuf/non_nested_extension.proto",
which is not imported
by "protobuf/java/src/test/java/com/google/protobuf/non_nested_extension.proto".
To use it here, please add the necessary import

How can I fix it?

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

prot...@googlecode.com

unread,
Dec 23, 2014, 5:21:02 AM12/23/14
to prot...@googlegroups.com

Comment #4 on issue 315 by Clear...@gmail.com: erroneous duplicate
definition error if imported file in subdirectory
https://code.google.com/p/protobuf/issues/detail?id=315

Hi All
When I use protoc to generate /nested_extension.proto from source(version
2.5.0), I get the error message:
exec]
protobuf/java/src/test/java/com/google/protobuf/non_nested_extension.proto:39:9: "protobuf_unittest.MessageToBeExtended"
is already defined in file "com/google/protobuf/non_nested_extension.proto".
[exec]
protobuf/java/src/test/java/com/google/protobuf/non_nested_extension.proto:43:9: "protobuf_unittest.MyNonNestedExtension"
is already defined in file "com/google/protobuf/non_nested_extension.proto".
[exec]
protobuf/java/src/test/java/com/google/protobuf/non_nested_extension.proto:47:33: "protobuf_unittest.nonNestedExtension"
is already defined in file "com/google/protobuf/non_nested_extension.proto".
[exec]
protobuf/java/src/test/java/com/google/protobuf/non_nested_extension.proto:46:8: "protobuf_unittest.MessageToBeExtended"
seems to be defined in "com/google/protobuf/non_nested_extension.proto",
which is not imported
by "protobuf/java/src/test/java/com/google/protobuf/non_nested_extension.proto".
To use it here, please add the necessary import

How can I fix it? thanks in advance.
Reply all
Reply to author
Forward
0 new messages