-
Notifications
You must be signed in to change notification settings - Fork 950
Description
steps
I'm working with Docker. The host's environment is:
- CPU: Apple M1 Max
- OS: macOS Sonoma 14.2
- Docker: Desktop 4.26.0, Engine 24.0.7
Dockerfile:
ARG base_image=centos:7
FROM $base_image
ARG jdk_version=8
ARG jdk_arch=x64
ARG jdk_platform=linux
ARG sbt_version=1.9.8
# setup java
ADD ./install_jdk.sh .
RUN ./install_jdk.sh ${jdk_version} ${jdk_arch} ${jdk_platform}
ENV JAVA_HOME /opt/jdk-${jdk_version}
ENV PATH $PATH:$JAVA_HOME/bin
# check installation
RUN java -version
RUN set -o pipefail && \
curl -q -L -o /etc/yum.repos.d/sbt-rpm.repo https://www.scala-sbt.org/sbt-rpm.repo && \
yum install -q -y sbt-${sbt_version}
RUN mkdir /app
WORKDIR /app
ENTRYPOINT ["/bin/bash"]
(install_jdk.sh
is a script that installs Adoptium Temurin JDK to /opt/jdk-${jdk_version}
using the latest official release archive. I uploaded it to gist: https://gist.github.com/mayth/12b20e6439e11c7f1ec1cb68a8d09d81)
Build an image, start a container and run sbt
in it.
$ docker build --platform linux/x86_64 --build-arg base_image=centos:7 --build-arg jdk_version=8 --build-arg jdk_arch=x64 sbt_version=1.9.8 -t sbt1.9.8-centos7-jdk8
$ docker run -it --rm --platform linux/x86_64 sbt1.9.8-centos7-jdk8 /usr/bin/sbt -batch sbtVersion
problem
Launching sbt fails with java.lang.UnsatisfiedLinkError: Error looking up function 'stat': java: undefined symbol: stat
.
As far as I tested, the same issue occurred on Rocky Linux 8 (--build-arg base_image=rockylinux:8
).
$ docker run -it --rm --platform linux/x86_64 sbt1.9.8-centos7-jdk8 /usr/bin/sbt -batch sbtVersion
downloading sbt launcher 1.9.8
[info] [launcher] getting org.scala-sbt sbt 1.9.8 (this may take some time)...
[info] [launcher] getting Scala 2.12.18 (for sbt)...
java.lang.UnsatisfiedLinkError: Error looking up function 'stat': java: undefined symbol: stat
at com.sun.jna.Function.<init>(Function.java:252)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:620)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:596)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:582)
at com.sun.jna.Library$Handler.invoke(Library.java:248)
at com.sun.proxy.$Proxy2.stat(Unknown Source)
at sbt.internal.io.Linux64Milli$.$anonfun$getModifiedTimeNative$1(Milli.scala:215)
at sbt.internal.io.MilliPosixBase.checkedIO(Milli.scala:100)
at sbt.internal.io.Linux64Milli$.getModifiedTimeNative(Milli.scala:215)
at sbt.internal.io.Linux64Milli$.getModifiedTimeNative(Milli.scala:210)
at sbt.internal.io.MilliNative.getModifiedTime(Milli.scala:65)
at sbt.internal.io.Milli$.getModifiedTime(Milli.scala:387)
at sbt.io.IO$.$anonfun$getModifiedTimeOrZero$1(IO.scala:1436)
at sbt.internal.io.Retry$.apply$mJc$sp(Retry.scala:47)
at sbt.internal.io.Retry$.apply$mJc$sp(Retry.scala:29)
at sbt.internal.io.Retry$.apply$mJc$sp(Retry.scala:24)
at sbt.io.IO$.getModifiedTimeOrZero(IO.scala:1436)
at sbt.internal.classpath.ClassLoaderCache$Key$$anonfun$$lessinit$greater$3.apply(ClassLoaderCache.scala:59)
at sbt.internal.classpath.ClassLoaderCache$Key$$anonfun$$lessinit$greater$3.apply(ClassLoaderCache.scala:59)
at scala.collection.immutable.List.map(List.scala:293)
at sbt.internal.classpath.ClassLoaderCache$Key.<init>(ClassLoaderCache.scala:59)
at sbt.internal.classpath.ClassLoaderCache$Key.<init>(ClassLoaderCache.scala:60)
at sbt.internal.classpath.ClassLoaderCache.cachedCustomClassloader(ClassLoaderCache.scala:195)
at sbt.State$StateOpsImpl$.initializeClassLoaderCache$extension(State.scala:417)
at sbt.StandardMain$.initialState(Main.scala:286)
at sbt.xMain$.$anonfun$run$11(Main.scala:128)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
at scala.Console$.withIn(Console.scala:230)
at sbt.internal.util.Terminal$.withIn(Terminal.scala:610)
at sbt.internal.util.Terminal$.$anonfun$withStreams$1(Terminal.scala:390)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
at scala.Console$.withOut(Console.scala:167)
at sbt.internal.util.Terminal$.$anonfun$withOut$2(Terminal.scala:600)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
at scala.Console$.withErr(Console.scala:196)
at sbt.internal.util.Terminal$.withOut(Terminal.scala:600)
at sbt.internal.util.Terminal$.withStreams(Terminal.scala:390)
at sbt.xMain$.withStreams$1(Main.scala:88)
at sbt.xMain$.run(Main.scala:123)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sbt.internal.XMainConfiguration.run(XMainConfiguration.java:59)
at sbt.xMain.run(Main.scala:47)
at xsbt.boot.Launch$.$anonfun$run$1(Launch.scala:149)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:176)
at xsbt.boot.Launch$.run(Launch.scala:149)
at xsbt.boot.Launch$.$anonfun$apply$1(Launch.scala:44)
at xsbt.boot.Launch$.launch(Launch.scala:159)
at xsbt.boot.Launch$.apply(Launch.scala:44)
at xsbt.boot.Launch$.apply(Launch.scala:21)
at xsbt.boot.Boot$.runImpl(Boot.scala:78)
at xsbt.boot.Boot$.run(Boot.scala:73)
at xsbt.boot.Boot$.main(Boot.scala:21)
at xsbt.boot.Boot.main(Boot.scala)
[error] [launcher] error during sbt launcher: java.lang.UnsatisfiedLinkError: Error looking up function 'stat': java: undefined symbol: stat
expectation
sbt should be successfully launched.
notes
- sbt 1.9.7 has no issue in the same condition.
- using Rocky Linux 9 (base=
rockylinux:9
) solves this problem. - using JDK 11+ also solves this problem.
- on aarch64 this problem doesn't occur.
This seems to be related with sbt/io#362 and #7455. As was done in #7455 (comment), I checked the symbol table of libc. I found that there is stat
in Rocky Linux 9 but not so in Rocky Linux 8. Rocky Linux 8 and 9 use glibc-2.28 and glibc-2.34 respectively.
In rockylinux:8 image (glibc-2.28):
$ readelf -s /lib64/ld-2.28.so | grep stat
2: 00000000000159d0 25 FUNC GLOBAL DEFAULT 12 _dl_get_tls_static_info@@GLIBC_PRIVATE
24: 00000000000071c0 5 FUNC GLOBAL DEFAULT 12 _dl_debug_state@@GLIBC_PRIVATE
39: 0000000000230040 4 OBJECT LOCAL DEFAULT 22 dl_close_state.11248
228: 000000000001df30 520 FUNC LOCAL DEFAULT 12 print_statistics_item
229: 000000000001e140 531 FUNC LOCAL DEFAULT 12 print_statistics
268: 0000000000000000 0 FILE LOCAL DEFAULT ABS dl-fxstatat64.c
285: 0000000000000000 0 FILE LOCAL DEFAULT ABS xstat.c
286: 0000000000000000 0 FILE LOCAL DEFAULT ABS fxstat.c
287: 0000000000000000 0 FILE LOCAL DEFAULT ABS lxstat.c
323: 0000000000023990 80 FUNC LOCAL DEFAULT 12 __GI___lxstat
360: 00000000000122e0 289 FUNC LOCAL DEFAULT 12 _dl_try_allocate_static_t
380: 0000000000012450 67 FUNC LOCAL DEFAULT 12 _dl_nothread_init_static_
383: 0000000000023990 80 FUNC LOCAL DEFAULT 12 _lxstat
384: 0000000000023900 80 FUNC LOCAL DEFAULT 12 _xstat
389: 0000000000023900 80 FUNC LOCAL DEFAULT 12 __xstat64
401: 0000000000023950 64 FUNC LOCAL DEFAULT 12 __GI___fxstat
409: 0000000000023900 80 FUNC LOCAL DEFAULT 12 __GI___xstat64
413: 0000000000023990 80 FUNC LOCAL DEFAULT 12 __lxstat
419: 0000000000023900 80 FUNC LOCAL DEFAULT 12 __GI___xstat
458: 0000000000023470 80 FUNC LOCAL DEFAULT 12 __fxstatat
481: 0000000000023470 80 FUNC LOCAL DEFAULT 12 __fxstatat64
496: 0000000000023470 80 FUNC LOCAL DEFAULT 12 __GI___fxstatat64
507: 0000000000012410 51 FUNC LOCAL DEFAULT 12 _dl_allocate_static_tls
523: 0000000000023950 64 FUNC LOCAL DEFAULT 12 __GI___fxstat64
526: 0000000000023990 80 FUNC LOCAL DEFAULT 12 __lxstat64
551: 0000000000023950 64 FUNC LOCAL DEFAULT 12 __fxstat64
554: 0000000000023900 80 FUNC LOCAL DEFAULT 12 __xstat
560: 0000000000023950 64 FUNC LOCAL DEFAULT 12 _fxstat
563: 00000000000071c0 5 FUNC LOCAL DEFAULT 12 __GI__dl_debug_state
570: 0000000000023950 64 FUNC LOCAL DEFAULT 12 __fxstat
571: 0000000000023990 80 FUNC LOCAL DEFAULT 12 __GI___lxstat64
611: 0000000000015600 140 FUNC LOCAL DEFAULT 12 _dl_tls_static_surplus_in
631: 00000000000159d0 25 FUNC GLOBAL DEFAULT 12 _dl_get_tls_static_info
633: 00000000000071c0 5 FUNC GLOBAL DEFAULT 12 _dl_debug_state
In rockylinux:9
(glibc-2.34):
# readelf -s /lib64/ld-linux-x86-64.so.2 | grep stat
40: 0000000000037060 4 OBJECT LOCAL DEFAULT 22 dl_close_state.2
235: 0000000000020fc0 536 FUNC LOCAL DEFAULT 13 print_statistics_item
236: 00000000000211e0 533 FUNC LOCAL DEFAULT 13 print_statistics
291: 0000000000000000 0 FILE LOCAL DEFAULT ABS stat64.c
292: 0000000000000000 0 FILE LOCAL DEFAULT ABS fstat64.c
293: 0000000000000000 0 FILE LOCAL DEFAULT ABS lstat64.c
294: 0000000000000000 0 FILE LOCAL DEFAULT ABS fstatat64.c
326: 00000000000270d0 48 FUNC LOCAL DEFAULT 13 __GI___fstat64
334: 0000000000027120 46 FUNC LOCAL DEFAULT 13 fstatat
345: 00000000000270b0 22 FUNC LOCAL DEFAULT 13 stat64
391: 00000000000270b0 22 FUNC LOCAL DEFAULT 13 __stat
401: 0000000000027120 46 FUNC LOCAL DEFAULT 13 __fstatat
425: 0000000000027100 25 FUNC LOCAL DEFAULT 13 __lstat64
428: 00000000000270d0 48 FUNC LOCAL DEFAULT 13 fstat64
438: 00000000000270b0 22 FUNC LOCAL DEFAULT 13 __stat64
457: 00000000000270d0 48 FUNC LOCAL DEFAULT 13 fstat
485: 0000000000027100 25 FUNC LOCAL DEFAULT 13 lstat
505: 0000000000027100 25 FUNC LOCAL DEFAULT 13 lstat64
541: 0000000000027100 25 FUNC LOCAL DEFAULT 13 __GI___lstat64
550: 0000000000027120 46 FUNC LOCAL DEFAULT 13 fstatat64
560: 00000000000270d0 48 FUNC LOCAL DEFAULT 13 __fstat64
566: 00000000000176d0 300 FUNC LOCAL DEFAULT 13 _dl_init_static_tls
580: 00000000000270b0 22 FUNC LOCAL DEFAULT 13 stat
581: 0000000000027120 46 FUNC LOCAL DEFAULT 13 __fstatat64
592: 00000000000270b0 22 FUNC LOCAL DEFAULT 13 __GI___stat64
596: 0000000000008300 5 FUNC LOCAL DEFAULT 13 __GI__dl_debug_state
609: 00000000000270d0 48 FUNC LOCAL DEFAULT 13 __fstat
612: 0000000000027100 25 FUNC LOCAL DEFAULT 13 __lstat
624: 0000000000027120 46 FUNC LOCAL DEFAULT 13 __GI___fstatat
640: 0000000000027120 46 FUNC LOCAL DEFAULT 13 __GI___fstatat64
649: 0000000000016a80 144 FUNC LOCAL DEFAULT 13 _dl_tls_static_s[...]
668: 0000000000016e40 25 FUNC GLOBAL DEFAULT 13 _dl_get_tls_stat[...]
671: 0000000000008300 5 FUNC GLOBAL DEFAULT 13 _dl_debug_state