scala-cli icon indicating copy to clipboard operation
scala-cli copied to clipboard

Selecting a JVM does not set its LD_LIBRARY_PATH

Open Flowdalic opened this issue 3 months ago • 0 comments

Version(s)

1.9.1

Describe the bug

Selecting a JVM does not set its LD_LIBRARY_PATH. Therefore, shared libraries provided by the JVM can not be loaded.

To Reproduce

Assume I want to use Graal VMs tracing agent:

$ scala-cli run \
        --jvm graalvm:21 \
        --java-opt -agentlib:native-image-agent=config-output-dir=`pwd`/trace \
        my.sc -- --help
Error occurred during initialization of VM
Could not find agent library native-image-agent on the library path, with error: libnative-image-agent.so: cannot open shared object file: No such file or directory

Instead, I have to manually set LD_LIBRARY_PATH

$ LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/flo/.cache/coursier/arc/https/github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/graalvm-ce-java17-linux-amd64-22.3.1.tar.gz/graalvm-ce-java17-22.3.1/lib" scala-cli run \
        --jvm graalvm:21 \
        --java-opt -agentlib:native-image-agent=config-output-dir=`pwd`/trace \
        my.sc -- --help

Expected behaviour

Selecting a JVM does not just entail running the according JVM binary. It also means adjusting the system library path (and PATH, if applicable). Therefore, scala-cli should do that.

Flowdalic avatar Sep 21 '25 19:09 Flowdalic