This question already has an answer here:
Here is a brief, self-explanatory bash session on Linux:
$ env | grep LD_LIBRARY_PATH $ export LD_LIBRARY_PATH=foo $ env | grep LD_LIBRARY_PATH LD_LIBRARY_PATH=foo $ echo $LD_LIBRARY_PATH foo
Here is the same session on a Mac:
$ env | grep LD_LIBRARY_PATH $ export LD_LIBRARY_PATH=foo $ env | grep LD_LIBRARY_PATH $ echo $LD_LIBRARY_PATH foo
Notice that, oddly,
env does not include
LD_LIBRARY_PATH, even though it has been exported, and echo finds it. But it's not just an
env thing. Other programs cannot find the environment variable. Here is a JVM (via the Scala REPL), after setting
scala> System.getenv("LD_LIBRARY_PATH") res0: String = null scala> System.getenv("SHELL") res1: String = /bin/bash
System.getenv("LD_LIBRARY_PATH") yields the expected
I'm trying to execute an external process from Scala that needs to inherit
LD_LIBRARY_PATH from the parent shell. But if the JVM can't see the parent shell's
LD_LIBRARY_PATH, and doesn't inherit automatically, it's hard to get right.
On Linux everything works as expected.
Thank you for your help!