diff --git a/docs/changelog.md b/docs/changelog.md index fb275dd5d..682221f0c 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -6,6 +6,9 @@ Requires libvips v8.12.2 ### v0.30.5 - TBD +* Install: pass `PKG_CONFIG_PATH` via env rather than substitution. + [@dwisiswant0](https://github.com/dwisiswant0) + * Allow installation of prebuilt libvips binaries from filesystem. [#3196](https://github.com/lovell/sharp/pull/3196) [@ankurparihar](https://github.com/ankurparihar) diff --git a/lib/libvips.js b/lib/libvips.js index e13db2074..3159a9bc9 100644 --- a/lib/libvips.js +++ b/lib/libvips.js @@ -65,7 +65,12 @@ const isRosetta = function () { const globalLibvipsVersion = function () { if (process.platform !== 'win32') { - const globalLibvipsVersion = spawnSync(`PKG_CONFIG_PATH="${pkgConfigPath()}" pkg-config --modversion vips-cpp`, spawnSyncOptions).stdout; + const globalLibvipsVersion = spawnSync('pkg-config --modversion vips-cpp', { + ...spawnSyncOptions, + env: { + PKG_CONFIG_PATH: pkgConfigPath() + } + }).stdout; /* istanbul ignore next */ return (globalLibvipsVersion || '').trim(); } else { @@ -85,7 +90,10 @@ const removeVendoredLibvips = function () { const pkgConfigPath = function () { if (process.platform !== 'win32') { - const brewPkgConfigPath = spawnSync('which brew >/dev/null 2>&1 && eval $(brew --env) && echo $PKG_CONFIG_LIBDIR', spawnSyncOptions).stdout || ''; + const brewPkgConfigPath = spawnSync( + 'which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2', + spawnSyncOptions + ).stdout || ''; return [ brewPkgConfigPath.trim(), env.PKG_CONFIG_PATH,