Open raboof opened 2 years ago
Same here.
same happens on Alpine Linux, which doesn't have glibc:
Caused by: java.io.IOException: Cannot run program "target/protoc-plugins/protoc-3.19.2-linux-x86_64.exe": error=2, No such file or directory
at java.lang.ProcessBuilder.start (ProcessBuilder.java:1143)
at java.lang.ProcessBuilder.start (ProcessBuilder.java:1073)
at java.lang.Runtime.exec (Runtime.java:594)
at org.codehaus.plexus.util.cli.Commandline.execute (Commandline.java:660)
at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLineAsCallable (CommandLineUtils.java:136)
at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine (CommandLineUtils.java:106)
at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine (CommandLineUtils.java:89)
at org.xolstice.maven.plugin.protobuf.Protoc.execute (Protoc.java:242)
is there a workaround that uses system protoc?
I got it running like so. I'm not a java buff, but the key is setting protoExecutable
to the protoc you'd like to use. In the nix case, just whatever is available on the path
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<protocExecutable>protoc</protocExecutable>
<protocArtifact>com.google.protobuf:protoc:3.22.0:exe:${os.detected.classifier}</protocArtifact>
</configuration>
</plugin>
Is your feature request related to a problem? Please describe.
When protobuf-maven-plugin downloads a protoc binary, that binary expects the ELF interpreter to exist at
/lib64/ld-linux-x86-64.so.2
. Unfortunately, on NixOS,/lib64/ld-linux-x86-64.so.2
does not exist, because different applications are allowed to use different versions of the loader. This means invoking the protoc compiler fails.Describe the solution you'd like
I would like the maven plugin to detect the
NIX_CC
environment variable on Linux, and when it exists, explicitly invoke$NIX_CC/nix-support/dynamic-linker
to load the protoc binary. This is the solution/workaround used by protoc-bridge as well.Describe alternatives you've considered
patchelf
utility to fix up the downloaded binary. This is inconvenient, since it is somewhat obscure, and would need to be repeated each time thetarget
directory is clearedAdditional context I understand this is something rather obscure. If you don't have objections againt the approach I'm happy to provide a PR implementing it.