From: s@... Date: 2018-08-14T20:00:19+00:00 Subject: [ruby-core:88487] [Ruby trunk Bug#14992] mkmf sets DYLD_LIBRARY_PATH on macOS which breaks pkg-config Issue #14992 has been reported by stevecheckoway (Stephen Checkoway). ---------------------------------------- Bug #14992: mkmf sets DYLD_LIBRARY_PATH on macOS which breaks pkg-config https://bugs.ruby-lang.org/issues/14992 * Author: stevecheckoway (Stephen Checkoway) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17] * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- 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`: ~~~ c #include #include 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. -- https://bugs.ruby-lang.org/ Unsubscribe: