Differences between LD_LIBRARY_PATH and ROOT_LIBRARY_PATH

I’m using Root 6.36.10 in an environment compiled with Spack, so LD_LIBRARY_PATH is empty but ROOT_LIBRARY_DIR correctly dontains the path of the lib/ folder of the environment. When trying to load a dynamic library from the shell I get:

# echo $LD_LIBRARY_PATH

# echo $ROOT_LIBRARY_PATH 
/software/spack/var/spack/environments/gseagen/.spack-env/view/lib/root:/software/spack/var/spack/environments/gseagen/.spack-env/view/lib64:/software/spack/var/spack/environments/gseagen/.spack-env/view/lib
# root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.36.10                        https://root.cern |
  | (c) 1995-2025, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Oct 16 2026, 09:39:39                 |
  | From tags/6-36-10@6-36-10                                        |
  | With g++ (Spack GCC) 15.2.0                                      |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

root [0] .L lib/libGPhQELEG-3.06.02.so
cling::DynamicLibraryManager::loadLibrary(): /software/install/linux-x86_64_v3/genie-3.6.2-uixeqzr6zjwsgzhqshqsquu2kzy2gqo2/lib/libGPhQELEG-3.06.02.so: undefined symbol: _ZTIN5genie22KineGeneratorWithCacheE

If I set the lib/ libraries to `LD_LIBRARY_PATH it works instead:

# export LD_LIBRARY_PATH=$ROOT_LIBRARY_PATH
# root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.36.10                        https://root.cern |
  | (c) 1995-2025, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Oct 16 2026, 09:39:39                 |
  | From tags/6-36-10@6-36-10                                        |
  | With g++ (Spack GCC) 15.2.0                                      |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

root [0] .L lib/libGPhQELEG-3.06.02.so
root [1] 

According to this post I initially thought that the two variables play the same role for Cling, with the Root-specific one available to avoid potential side effects with other applications using LD_LIBRARY_PATH, but my tests show that it’s not the case.
So what are the differences and the intended usage withing Cling of the two variables? Thanks.

ROOT will search for some requested shared library in the “ROOT_LIBRARY_PATH”. Still, this variable will NOT be used by the dynamic linker to find and load other shared libraries that your requested shared library depends on. The dynamic linker will only see shared libraries in the “LD_LIBRARY_PATH” (and “RPATH” and “RUNPATH” set in your requested shared library, of course).

See also (try the “brutal fix”):