Julia in docker could not find packages in `$JULIA_LOAD_PATH`

I’m using Julia inside a docker container. I set $JULIA_LOAD_PATH to $load_path:, where $load_path contains

$ ls $load_path
...
Compat
...
NNlib
...
$ cat $load_path/Compat/Project.toml
...

[extensions]
CompatLinearAlgebraExt = "LinearAlgebra"
$ ls $load_path/Compat/ext/
CompatLinearAlgebraExt.jl

However, I could not load NNlib.jl:

$ julia -e "using NNlib"
Info Given NNlib was explicitly requested, output will be shown live
ERROR: LoadError: ArgumentError: Package CompatLinearAlgebraExt [dbe5ba0b-aecc-598a-a867-79051b540f49] is required but does not seem to be installed:
 - Run `Pkg.instantiate()` to install all recorded dependencies.

Why can’t Julia find CompatLinearAlgebraExt?

Moreover, I set $JULIA_DEPOT_PATH to .julia:precompiled-depot, where precompiled-depot/compiled contains precompiled files (but compiled outside of docker), but Julia seems to completely ignore them.

$ ls precompiled-depot
artifacts compiled

Upon further inspection, the filenames inside compiled is different. It seems like precompiling inside and outside of the docker image makes a difference. The Sys.CPU_NAME variable inside and outside of the image show znver1.

bash-5.3# ls .julia/compiled/v1.12/HTTP
zXWya_7qVsF.ji	zXWya_7qVsF.so
bash-5.3# ls precompiled-depot/compiled/v1.12/HTTP
zXWya_mJgfz.ji	zXWya_mJgfz.so

Could you provide a complete MWE, including the Dockerfile, the command you used to launch the container, and the command you used to set the environment variables?

I always precompile inside the image, as a build step in Dockerfile, after setting the environment variable JULIA_CPU_TARGET to one that works for generic machines.

1 Like