How did adding /usr/lib/
to my DYLD_LIBRARY_PATH cause this dynamic linking problem on my MacOS Ventura M1 MBP?
I had set export DYLD_LIBRARY_PATH="...:/usr/lib:..."
in my .bash_profile
.
$ xz --version
dyld[52238]: Symbol not found: _lzma_cputhreads
Referenced from: <2057FB51-46E1-3DB6-B2E8-DCB023BF98DC> /opt/homebrew/Cellar/xz/5.4.3/bin/xz
Expected in: <D0CF8623-5E85-35D2-8ABA-8A7F0002AB0A> /usr/lib/liblzma.5.dylib
Abort trap: 6
$ otool -L /opt/homebrew/Cellar/xz/5.4.3/bin/xz
/opt/homebrew/Cellar/xz/5.4.3/bin/xz:
/opt/homebrew/Cellar/xz/5.4.3/lib/liblzma.5.dylib (compatibility version 10.0.0, current version 10.3.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.100.3)
Unsetting this variable fixed my immediate problem.
$ DYLD_LIBRARY_PATH="" xz --version
xz (XZ Utils) 5.4.3
liblzma 5.4.3
However, looking in /usr/lib
, I cannot find why my system thinks there was a version of liblzma in /usr/lib
at all.
$ ls /usr/lib | grep 'liblzma'
$ find /usr/lib -name '*liblzma*'
$
I could understand seeing these symptoms if there was a version of liblzma in that directory, but there does not appear to be. /usr/lib
was neither the first nor the last path in that list, so I don't understand why the failure would manifest that way in particular. So why did having that directory on my DYLD_LIBRARY_PATH
cause my system trying to link to a dylib in that directory, even though said dylib does not exist at that location?
which
to see what library is in your path:which liblzma
. Then you’ll know where it’s located…if it’s in your pathDYLD_LIBRARY_PATH
which triggered the error? Maybe the order of paths in there matter."$HOMEBREW_PREFIX/opt/sqlite/lib:/usr/lib:/Applications/azprolog.app/Contents/az_home/lib"
I was confused and surprised that the failure was related to the path in the middle.