R__LOAD_LIBRARY and gSystem-Load() both ignore LD_LIBRARY_PATH and load the libraries from the same directory as the root libraries (/usr/local/lib in this case).
The problem is that ROOT “prepends” its own “root-config --libdir” to the list of searched directories from the “LD_LIBRARY_PATH” (and then appends the “.” directory).
You can easily see it, just try: gSystem->Load("NonExistent");
I would really prefer to have “.:${LD_LIBRARY_PATH}:/anything:/else:/useful” (where “LD_LIBRARY_PATH” is exactly what the user provided, without ANY modifications).
This is actually a bug in the “root” executable, which internally modifies its own “LD_LIBRARY_PATH” value: std::cout << gSystem->ExpandPathName("${LD_LIBRARY_PATH}") << std::endl;
For the time being, this does NOT happen if you use the “root.exe” executable, though. So, running “root.exe” (instead of “root”) is a possible brutal fix.
You can also try to apply another brutal fix (in your “rootlogon.C” file): gSystem->SetDynamicPath(TString::Format("/my/preferred/path:%s", gSystem->GetDynamicPath()));
In my case, the root installation is inside a container so there is only ever one version of root. Would you still recommend never installing into /usr/local?