After upgrading to macOS 15.4 recently, I am not able to run fenicsx-based codes. I get a lot of dlopen errors regarding duplicate LC_RPATH entries. I installed via conda originally.
**ImportError** : dlopen(/Users/bosmacs/.cache/fenics/libffcx_forms_2776970e29d8246dcb3b0507cb5e1b1509b9e159.cpython-313-darwin.so, 0x0002): tried: '/Users/bosmacs/.cache/fenics/libffcx_forms_2776970e29d8246dcb3b0507cb5e1b1509b9e159.cpython-313-darwin.so' (duplicate LC_RPATH '/Users/bosmacs/Repos/dh-solver/.pixi/envs/default/lib'), '/System/Volumes/Preboot/Cryptexes/OS/Users/bosmacs/.cache/fenics/libffcx_forms_2776970e29d8246dcb3b0507cb5e1b1509b9e159.cpython-313-darwin.so' (no such file), '/Users/bosmacs/.cache/fenics/libffcx_forms_2776970e29d8246dcb3b0507cb5e1b1509b9e159.cpython-313-darwin.so' (duplicate LC_RPATH '/Users/bosmacs/Repos/dh-solver/.pixi/envs/default/lib')
Removing the .cache/fenics folder does not seem to help, they are simply regenerated. I can confirm with otool that there are duplicate entries:
Yes, I’ve just discovered the same problem applies to ffcx outputs because rpaths are duplicated from Python’s LDSHARED and the default $LDFLAGS. That makes removing them more complex. I believe you can fix it by setting the $LDSHARED environment variable:
libgfortran is fixed if you have libgfortran5=14.* This should be the default for most folks with recently updated or created envs, but if your env hasn’t had an update in a while, conda update libgfortran5 should do it
The linker has been fixed to turn these duplicate rpaths into warnings (as the new default Apple linker has been doing since xcode 15), so if you update ld64 to at least build 6 (ld64=951.9=h4c6efb1_6 on mac arm)
So in short, an env should be fixed with:
mamba update libgfortran5 ld64
without needing to patch anything. You may need to clean your ffcx cache.
Thanks, cleaning the cache and updating the packages finally solved my problem.
(I needed to force the ld64 version in the update command to make it work.)