Open zikolach opened 7 years ago
Thank you. I suppose any Linux binary requiring those shared libs would fail?
BTW Google has started providing protoc binaries for Linux. I guess they fail too, but I'd be curious:
java -jar protoc-jar-3.1.0.3.jar -v:com.google.protobuf:protoc:2.6.1 --version
I suppose so too, but I'd like to see this limitation in Readme. Otherwise "crossplatform" looks kond of misleading ;)
$ docker run -it --rm openjdk:alpine sh
Unable to find image 'openjdk:alpine' locally
alpine: Pulling from library/openjdk
b7f33cc0b48e: Already exists
43a564ae36a3: Already exists
b294f0e7874b: Pull complete
Digest: sha256:21204d8264c0670ae35a18439cd0bf1d91055181fff75aeeb1d1840becfb189c
Status: Downloaded newer image for openjdk:alpine
/ # apk add --no-cache curl && curl -sL http://central.maven.org/maven2/com/github/os72/protoc-jar/3.1.0.3/protoc-jar-3.1.0.3.jar > protoc-jar-3.1.0.3.jar
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
(1/3) Installing libssh2 (1.7.0-r0)
(2/3) Installing libcurl (7.52.1-r0)
(3/3) Installing curl (7.52.1-r0)
Executing busybox-1.24.2-r12.trigger
OK: 141 MiB in 38 packages
/ # java -jar protoc-jar-3.1.0.3.jar -v:com.google.protobuf:protoc:2.6.1 --version
protoc-jar: protoc version: com.google.protobuf:protoc:2.6.1, detected platform: linux/amd64
protoc-jar: downloading: http://central.maven.org/maven2/com/google/protobuf/protoc/2.6.1/protoc-2.6.1-linux-x86_64.exe
protoc-jar: cached: /tmp/protocjar.webcache/com/google/protobuf/protoc/2.6.1/protoc-2.6.1-linux-x86_64.exe
protoc-jar: executing: [/tmp/protocjar2377083706208738892/bin/protoc.exe, --version]
java.io.IOException: Cannot run program "/tmp/protocjar2377083706208738892/bin/protoc.exe": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at com.github.os72.protocjar.Protoc.runProtoc(Protoc.java:88)
at com.github.os72.protocjar.Protoc.runProtoc(Protoc.java:55)
at com.github.os72.protocjar.Protoc.main(Protoc.java:37)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 3 more
/ #
BTW Google has started providing protoc binaries for Linux. I guess they fail too.
Exactly
Yes, it's obviously limited cross-platform. And Linux comes in a lot of flavors. But we could keep it as an open issue
the alpine have protoc lib but not work. in alpine install like this: apk update && apk add protobuf protobuf-dev but protoc-jar download google protoc lib , so can't run in the alpine .
This is not protoc-jar bug . is alpine not have glibc . Look this : only install glibc-2.25-r1.apk well OK . https://github.com/sgerrand/alpine-pkg-glibc
cp sgerrand.rsa.pub /etc/apk/keys/sgerrand.rsa.pub
/data # apk add glibc-2.25-r1.apk
(1/1) Installing glibc (2.25-r1)
OK: 153 MiB in 39 packages
/data # java -jar protoc-jar-3.1.0.3.jar -v:com.google.protobuf:protoc:2.6.1 --version
protoc-jar: protoc version: com.google.protobuf:protoc:2.6.1, detected platform: linux/amd64
protoc-jar: cached: /tmp/protocjar.webcache/com/google/protobuf/protoc/2.6.1/protoc-2.6.1-linux-x86_64.exe
protoc-jar: executing: [/tmp/protocjar5724818814734029924/bin/protoc.exe, --version]
libprotoc 2.6.1
/data # cat /etc/issue
Welcome to Alpine Linux 3.4
Kernel \r on an \m (\l)
/data #
Thanks!
Similar problem on nix. I submitted a patch to scalapb to allow it to just use a custom protoc: https://github.com/scalapb/ScalaPB/pull/367/files#diff-b20ee6b52802a4ee05c85a29da7026c2
Faced with same problem.
Why not using protobuf statically compiled? It would work regardless of glibc or musl being the libc! Other thing I cannot get is why on the first place it requires to be native, there is no protobuf alternative written in java?
Why not using protobuf statically compiled? It would work regardless of glibc or musl being the libc!
I guess that would solve this issue, yes.
Other thing I cannot get is why on the first place it requires to be native, there is no protobuf alternative written in java?
I don't know of a Java implementation, but if you know of one, then sure, that would be perfect.
I also ran into the issue of the downloaded protoc
not working on Alpine Linux.
@os72 Could protoc-jar add a statically compiled protoc
binary for Linux which would work on Linux regardless of the C standard library used by the distribution (glibc/musl)? Or could protoc-jar add an extra protoc
binary that dynamically links against musl instead of glibc? (I guess protoc-jar's PlatformDetector
would need to be extended to detect the C library in that case.) Or would Google need to add binaries on Maven Central that work on Alpine Linux?
I just found that if you install the gcompat
package ("The GNU C Library compatibility layer for musl") on Alpine, then the binary from Google does work.
Without gcompat
it indeed fails:
% docker run -it --rm alpine
/ # wget https://repo.maven.apache.org/maven2/com/google/protobuf/protoc/3.11.4/protoc-3.11.4-linux-x86_64.exe
Connecting to repo.maven.apache.org (151.101.36.215:443)
saving to 'protoc-3.11.4-linux-x86_64.exe'
protoc-3.11.4-linux- 100% |*******************************************************************************************************************************************| 4972k 0:00:00 ETA
'protoc-3.11.4-linux-x86_64.exe' saved
/ # chmod +x protoc-3.11.4-linux-x86_64.exe
/ # ./protoc-3.11.4-linux-x86_64.exe --version
/bin/sh: ./protoc-3.11.4-linux-x86_64.exe: not found
/ # ldd protoc-3.11.4-linux-x86_64.exe
/lib64/ld-linux-x86-64.so.2 (0x7fa2f50ac000)
libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7fa2f50ac000)
libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7fa2f50ac000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7fa2f50ac000)
Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by protoc-3.11.4-linux-x86_64.exe)
Error relocating protoc-3.11.4-linux-x86_64.exe: __strftime_l: symbol not found
But after adding gcompat
it seems to work:
/ # apk add gcompat
(1/3) Installing musl-obstack (1.1-r1)
(2/3) Installing libucontext (1.0-r0)
(3/3) Installing gcompat (1.0.0-r1)
OK: 6 MiB in 17 packages
/ # ./protoc-3.11.4-linux-x86_64.exe --version
libprotoc 3.11.4
No sure at all if it is an issue with protoc-jar - just noticed strange behaviour running build on Alpine.
In case anyone will have trouble there is workaround:
Found it here
Of course it is possible to set custom
PB.runProtoc
, but then it wouldn't cross-platform.