Skip to content

Commit 0e6ea6d

Browse files
committed
[core] Follow symlinks in TROOT::GetSharedLibDir()
The idea is to find the actual ROOT install directory, so we have to follow symlinks. The `info->dlpi_name` doesn't do that, so we need to do that ourselves with `fs::canonical()`. Closes #21031.
1 parent 4cfaed9 commit 0e6ea6d

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

core/base/src/TROOT.cxx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3159,7 +3159,18 @@ const TString &TROOT::GetSharedLibDir()
31593159

31603160
fs::path p = info->dlpi_name;
31613161
if (p.filename() == _R_QUOTEVAL_(LIB_CORE_NAME)) {
3162-
libdir = p.parent_path().c_str();
3162+
std::error_code ec;
3163+
3164+
// Resolve symlinks: critical for environments like CMSSW, where the
3165+
// ROOT libraries are loaded via symlinks that point to the actual
3166+
// install directory
3167+
fs::path resolved = fs::canonical(p, ec);
3168+
if (ec) {
3169+
// Fall back to the loader path if canonicalization fails. The path
3170+
// will likely be wrong, but at least not garbage
3171+
resolved = p;
3172+
}
3173+
libdir = resolved.parent_path().c_str();
31633174
return 1; // stop iteration
31643175
}
31653176
return 0; // continue

0 commit comments

Comments
 (0)