Actions
Bug #14992
closedmkmf sets DYLD_LIBRARY_PATH on macOS which breaks pkg-config
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
Description
When mkmf
runs pkg-config
, it sets DYLD_LIBRARY_PATH
on macOS which causes pkg-config
to not work. As an example, running
$ ruby2.5 -r mkmf -e 'pkg_config("libxml-2.0")'
writes the following to mkmf.log
.
"pkg-config --exists libxml-2.0"
dyld: Symbol not found: __cg_jpeg_resync_to_restart
Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /opt/local/lib/libJPEG.dylib
in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
package configuration for libxml-2.0 is not found
The same behavior results from running pkg-config
with DYLD_LIBRARY_PATH
set.
$ DYLD_LIBRARY_PATH=.:/opt/local/lib pkg-config --exists libxml-2.0
dyld: Symbol not found: __cg_jpeg_resync_to_restart
Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Expected in: /opt/local/lib/libJPEG.dylib
in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
Abort trap: 6
I verified that mkmf
is responsible for setting this by writing the following pkg-config.c
file, compiling it as pkg-config
, and then running the ruby2.5
command above with .
at the front of my PATH
.
pkg-config.c
:
#include <stdio.h>
#include <stdlib.h>
int main() {
printf("DYLD_LIBRARY_PATH=%s\n", getenv("DYLD_LIBRARY_PATH"));
return 1;
}
$ ./pkg-config
DYLD_LIBRARY_PATH=(null)
$ PATH=.:$PATH ruby2.5 -r mkmf -e 'pkg_config("libxml-2.0")'
$ cat mkmf.log
"pkg-config --exists libxml-2.0"
DYLD_LIBRARY_PATH=.:/opt/local/lib
package configuration for libxml-2.0 is not found
I don't know why DYLD_LIBRARY_PATH
is being set, but I don't believe it should be. It's not respected by system binaries on macOS and macOS has supported methods of embedding run-time paths in binaries, executables, and bundles that probably should be used instead.
Actions
Like0
Like0Like0