Sample Header Ad - 728x90

Why does my DYLD_LIBRARY_PATH makes dynamic linker see a dylib that`ls` does not show me?

0 votes
0 answers
430 views
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: Symbol not found: _lzma_cputhreads
  Referenced from:  /opt/homebrew/Cellar/xz/5.4.3/bin/xz
  Expected in:      /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?
Asked by Jason Hemann (123 rep)
Jun 29, 2023, 12:39 PM
Last activity: Jun 30, 2023, 07:35 AM