0
votes

I'm trying to compile protocol buffers code using the maven protoc plugin and a protoc executable that I built inside Cygwin. I can't do this from Cygwin or from the Windows command line. Below is the output that I get when I run it in Windows, but the error is identical when running from Cygwin. I find this strange because if the issue was with path translation then I'd expect one of them to work. Is it possible that the fact that the executable was built with Cygwin's g++ could affect things? (To state the obvious, the directory in question does exist.)

Edit: I get the same error when I take maven out of the picture and just invoke protoc by hand.

Edit 2: I can fix this by invoking protoc by hand from Cygwin using relative or absolute paths (but tilde-expansion does not work). Invoking protoc by hand from Windows using relative or absolute paths continues to give the same error.

[DEBUG]   (f) outputDirectory = c:\cygwin64\home\dan\code\server\protocol\target\generated-sources\protobuf\java
[DEBUG]   (f) project = MavenProject: server:protocol:1.0-SNAPSHOT @ c:\cygwin64\home\dan\code\server\protocol\pom.xml
[DEBUG]   (f) protoSourceRoot = c:\cygwin64\home\dan\code\server\protocol\src\main\proto
[DEBUG]   (f) protocPluginDirectory = c:\cygwin64\home\dan\code\server\protocol\target\protoc-plugins
[DEBUG]   (f) remoteRepositories = [
      id: central
      url: https://repo.maven.apache.org/maven2
      layout: default snapshots: [enabled => false, update => daily]
      releases: [enabled => true, update => daily]
      ]
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@24fb6a80
[DEBUG]   (f) skip = false
[DEBUG]   (f) staleMillis = 0
[DEBUG]   (f) temporaryProtoFileDirectory = c:\cygwin64\home\dan\code\server\protocol\target\protoc-dependencies
[DEBUG]   (f) writeDescriptorSet = false
[DEBUG] -- end configuration --
[WARNING] No 'protocExecutable' parameter is configured, using the default: 'protoc'
[DEBUG] Proto source root:
[DEBUG]  c:\cygwin64\home\dan\code\server\protocol\src\main\proto
[DEBUG] [PROTOC] Executable:
[DEBUG] [PROTOC]  protoc
[DEBUG] [PROTOC] Protobuf import paths:
[DEBUG] [PROTOC]  c:\cygwin64\home\dan\code\server\protocol\src\main\proto [DEBUG] [PROTOC] Java output directory:
[DEBUG] [PROTOC]  c:\cygwin64\home\dan\code\server\protocol\target\generated-sources\protobuf\java
[DEBUG] [PROTOC] Protobuf descriptors:
[DEBUG] [PROTOC]  c:\cygwin64\home\dan\code\server\protocol\src\main\proto\message.proto
[DEBUG] [PROTOC] Command line options:
[DEBUG] [PROTOC]
    --proto_path=c:\cygwin64\home\dan\code\server\protocol\src\main\proto
    --java_out=c:\cygwin64\home\dan\code\server\protocol\target\generated-sources\protobuf\java
    c:\cygwin64\home\dan\code\server\protocol\src\main\proto\message.proto
[INFO] Compiling 1 proto file(s) to c:\cygwin64\home\dan\code\server\protocol\target\generated-sources\protobuf\java
[ERROR] PROTOC FAILED: c: warning: directory does not exist. c:\cygwin64\home\dan\code\server\protocol\src\main\proto\message.proto: File does not reside within any path specified using --proto_path (or -I).  You must specify a --proto_path which encompasses this file. Note that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equivalent (it's harder than you think).
1

1 Answers

2
votes

Executables that you build using Cygwin will depend on the full Cygwin environment and will behave as Cygwin programs, regardless of how you execute them. That is, if you execute a Cygwin program from the non-Cygwin shell, it will still behave as a Cygwin program. Cygwin programs do not accept Windows-style paths that use backslashes an drive letters; you need to use e.g. /cygdrive/c/ instead of c:\.

In general, you should not attempt to use Cygwin-compiled command-line tools from a non-Cygwin shell. Instead, try building protoc using MSVC or MinGW, or use the pre-built Windows binaries that Google provides.