os72 / protoc-jar-maven-plugin

Protocol Buffers protobuf maven plugin - based on protoc-jar multi-platform executable protoc JAR
http://os72.github.io/protoc-jar-maven-plugin/
Apache License 2.0
253 stars 79 forks source link

Error running on Alpine docker #65

Open ErikThorsell opened 5 years ago

ErikThorsell commented 5 years ago

Perhaps related to https://github.com/os72/protoc-jar-maven-plugin/issues/39.

After downloading plugin (version 3.6.0.1), as part of a pom.xml on a Jenkins agent based on an alpine-image, I get the following error:

[INFO] Protoc version: 3.6.0
protoc-jar: protoc version: 3.6.0, detected platform: linux-x86_64 (linux/amd64)
protoc-jar: embedded: bin/3.6.0/protoc-3.6.0-linux-x86_64.exe
protoc-jar: executing: [/tmp/protocjar12635287816338122886/bin/protoc.exe, --version]
protoc-jar: caught exception, retrying: java.io.IOException: Cannot run program "/tmp/protocjar12635287816338122886/bin/protoc.exe": error=2, No such file or directory
protoc-jar: executing: [/tmp/protocjar12635287816338122886/bin/protoc.exe, --version]
protoc-jar: caught exception, retrying: java.io.IOException: Cannot run program "/tmp/protocjar12635287816338122886/bin/protoc.exe": error=2, No such file or directory
protoc-jar: executing: [/tmp/protocjar12635287816338122886/bin/protoc.exe, --version]
protoc-jar: protoc version: 3.6.0, detected platform: linux-x86_64 (linux/amd64)
protoc-jar: embedded: bin/3.6.0/protoc-3.6.0-linux-x86_64.exe
[INFO] Protoc command: /root/protocjar17242107685880089516/bin/protoc.exe
[INFO] Input directories:
[INFO]     /root/workspace/jenkinsfile-test-U6PQZV3G2CJQNIADJADVA4QMJ6AJP2SFIO3MJWXBEQF7WW2TYCBA/src/main/protobuf
[INFO] Output targets:
[INFO]     java: /root/workspace/_jenkinsfile-test-U6PQZV3G2CJQNIADJADVA4QMJ6AJP2SFIO3MJWXBEQF7WW2TYCBA/target/generated-sources (add: main, clean: false, plugin: null, outputOptions: null)
[INFO] /root/workspace/jenkinsfile-test-U6PQZV3G2CJQNIADJADVA4QMJ6AJP2SFIO3MJWXBEQF7WW2TYCBA/target/generated-sources does not exist. Creating...
[INFO]     Processing (java): mission.proto
protoc-jar: executing: [/root/protocjar17242107685880089516/bin/protoc.exe, -I/root/workspace/jenkinsfile-test-U6PQZV3G2CJQNIADJADVA4QMJ6AJP2SFIO3MJWXBEQF7WW2TYCBA/src/main/protobuf, --java_out=/root/workspace/jenkinsfile-test-U6PQZV3G2CJQNIADJADVA4QMJ6AJP2SFIO3MJWXBEQF7WW2TYCBA/target/generated-sources, /root/workspace/jenkinsfile-test-U6PQZV3G2CJQNIADJADVA4QMJ6AJP2SFIO3MJWXBEQF7WW2TYCBA/src/main/protobuf/mission.proto]
protoc-jar: caught exception, retrying: java.io.IOException: Cannot run program "/root/protocjar17242107685880089516/bin/protoc.exe": error=2, No such file or directory
protoc-jar: executing: [/root/protocjar17242107685880089516/bin/protoc.exe, -I/root/workspace/jenkinsfile-test-U6PQZV3G2CJQNIADJADVA4QMJ6AJP2SFIO3MJWXBEQF7WW2TYCBA/src/main/protobuf, --java_out=/root/workspace/jenkinsfile-test-U6PQZV3G2CJQNIADJADVA4QMJ6AJP2SFIO3MJWXBEQF7WW2TYCBA/target/generated-sources, /root/workspace/jenkinsfile-test-U6PQZV3G2CJQNIADJADVA4QMJ6AJP2SFIO3MJWXBEQF7WW2TYCBA/src/main/protobuf/mission.proto]
protoc-jar: caught exception, retrying: java.io.IOException: Cannot run program "/root/protocjar17242107685880089516/bin/protoc.exe": error=2, No such file or directory
protoc-jar: executing: [/root/protocjar17242107685880089516/bin/protoc.exe, -I/root/workspace/jenkinsfile-test-U6PQZV3G2CJQNIADJADVA4QMJ6AJP2SFIO3MJWXBEQF7WW2TYCBA/src/main/protobuf, --java_out=/root/workspace/jenkinsfile-test-U6PQZV3G2CJQNIADJADVA4QMJ6AJP2SFIO3MJWXBEQF7WW2TYCBA/target/generated-sources, /root/workspace/jenkinsfile-test-U6PQZV3G2CJQNIADJADVA4QMJ6AJP2SFIO3MJWXBEQF7WW2TYCBA/src/main/protobuf/mission.proto]

Running the exact same project on my local machine (Windows 10) works just fine.

It seems like the plugin thinks it's running on Windows (since it's attempting to execute .exe-files). I have yet to find a workaround that works both in my CI system and locally.

os72 commented 5 years ago

It detects Linux just fine (bin/3.6.0/protoc-3.6.0-linux-x86_64.exe) but yes it seems the system isn't compatible. It rather looks like https://github.com/os72/protoc-jar/issues/15, missing glibc or so

michaelkrupp commented 5 years ago

Any plans on supporting a locally provided protoc, instead of the ones shipped with protoc-jar? This would basically fix the issue of running on Alpine.

Edit: nevermind, you actually already do this and are just missing the documentation for it: https://github.com/os72/protoc-jar-maven-plugin/blob/master/src/main/java/com/github/os72/protocjar/maven/ProtocJarMojo.java#L265

contrun commented 5 years ago

How can I change the protoc command path?

michaelkrupp commented 5 years ago
<plugin>
    <artifactId>protoc-jar-maven-plugin</artifactId>
    <groupId>com.github.os72</groupId>
    <configuration>
        <protocCommand>protoc</protocCommand>
    </configuration>
</plugin>

@contrun does this answer your question? :-)

contrun commented 5 years ago

@michaelkrupp Thanks

bmarwell commented 5 years ago

Is this maybe related to the download issue I had?

Try to specify the artifact yourself: <pluginArtifact>com.google.protobuf:protoc:${dependency.protobuf.version}</pluginArtifact> This will force this plugin to do maven resolution instead of trying to download it manually.

os72 commented 5 years ago

@bmhm This is a runtime issue. See os72/protoc-jar#15, missing glibc or so

breun commented 3 years ago

As a workaround I've found you can add the gcompact package (apk add gcompat), which will provide a glibc compatibility layer for Alpine's musl C library.