An error occurred while fetching participants.
Dynamic library search fails on macOS if solver is executed using foamJob script
Summary
Dynamic library search fails on macOS if solver is executed using foamJob
script because SIP clears DYLD_LIBRARY_PATH
variable.
Steps to reproduce
Execute any case, which loads additional dynamic libraries, using foamJob
script.
Example case
initChannel case from tutorials/incompressible/pimpleFoam/LES/surfaceMountedCube
. In Allrun
script I have changed runApplication simpleFoam
to foamJob simpleFoam
.
What is the current bug behaviour?
Upon execution solver prints warning about missing libraries:
--> FOAM Warning :
From void *Foam::dlLibraryTable::openLibrary(const Foam::fileName &, bool)
in file db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C at line 188
Could not load "fieldFunctionObjects"
dlopen(libfieldFunctionObjects.dylib, 0x0009): tried: 'libfieldFunctionObjects.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibfieldFunctionObjects.dylib' (no such file), '/usr/lib/libfieldFunctionObjects.dylib' (no such file, not in dyld cache), 'libfieldFunctionObjects.dylib' (no such file), '/usr/local/lib/libfieldFunctionObjects.dylib' (no such file), '/usr/lib/libfieldFunctionObjects.dylib' (no such file, not in dyld cache)
--> FOAM Warning :
Unknown function type turbulenceFields
What is the expected correct behavior?
Solver finds requested libraries and loads them.
Relevant logs and/or images
See attached log.gz.
Environment information
- OpenFOAM version : v2206 and vdev (868d6dd7)
- Operating system : macOS 13.4
- Compiler : Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Possible fixes
Restore DYLD_LIBRARY_PATH
from FOAM_DYLD_LIBRARY_PATH
, like in RunFunctions
:
# Darwin workaround - SIP clearing DYLD_LIBRARY_PATH variable
if [ -n "$FOAM_DYLD_LIBRARY_PATH" ] && [ -z "$DYLD_LIBRARY_PATH" ]
then
export DYLD_LIBRARY_PATH="$FOAM_DYLD_LIBRARY_PATH"
fi