Skip to content

Support pkg-config finding dependencies on Linux systems #4504

Closed

Description

@rektide

Feature request

What are you trying to achieve?

It would be great if building from source worked reliably on more Linux distributions.

Currently there are a very limited number of pkg-config paths (PKG_CONFIG_PATH) that are looked at:

const pkgConfigPath = () => {

However if we look at where dependencies get installed, there are a variety of places on various Linux distributions where packages and pkg-config .pc files get installed.

When you searched for similar feature requests, what did you find that might be related?

I've searched for pkg-config and pkgconfig and browsed issues.

What would you expect the API to look like?

This is a little bit of a trickly problem, because distros use different directories, and the directory is often architecture specific.

Rather than propose one path, let's look at some examples in various distros, in this case for the dependency libhwy on amd64:

Some possible tools we might use to understand what pkgconfig path to try to use:

  • pkg-config --variable pc_path pkg-config will ask pkg-config for the pkgconfig path of the pkgconfig library.
  • uname -m which returns x86_64
  • uname -o which returns GNU/Linux?

What alternatives have you considered?

We can try to ask pkg-config to tell us it's own configuration if we need a base path, and have pkg-config

Please provide sample image(s) that help explain this feature

example failure of building on Debian
$ pnpm i                                                                                                                packages/auto-icons
Scope: all 16 workspace projects
../..                                    |   +1 +
../..                                    | Progress: resolved 1, reused 1, downloaded 0, added 1, done
../../node_modules/.pnpm/[email protected]/node_modules/sharp: Running install script, failed in 754ms
.../[email protected]/node_modules/sharp install$ node install/check.js || npm run build
│ npm warn Unknown env config "npm-globalconfig". This will stop working in the next major version of npm. See `npm help npmrc` for support…
│ npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm. See `npm help npmrc` for s…
│ npm warn Unknown env config "_jsr-registry". This will stop working in the next major version of npm. See `npm help npmrc` for supported …
│ npm warn Unknown env config "patched-dependencies". This will stop working in the next major version of npm. See `npm help npmrc` for sup…
│ npm warn Unknown env config "peer-dependency-rules". This will stop working in the next major version of npm. See `npm help npmrc` for su…
│ > [email protected] build
│ > node install/build.js
│ sharp: Attempting to build from source via node-gyp
│ sharp: See https://sharp.pixelplumbing.com/install#building-from-source
│ sharp: Found node-addon-api
│ sharp: Found node-gyp 12.2.0
│ sharp: Detected globally-installed libvips v8.18.0
│ gyp info it worked if it ends with ok
│ gyp info using [email protected]
│ gyp info using [email protected] | linux | x64
│ gyp info chdir src
│ (node:2893051) [DEP0169] DeprecationWarning: `url.parse()` behavior is not standardized and prone to errors that have security implicatio…
│ (Use `node --trace-deprecation ...` to show where the warning was created)
│ gyp info find Python using Python version 3.13.11 found at "/usr/bin/python3"
│ gyp info spawn /usr/bin/python3
│ gyp info spawn args [
│ gyp info spawn args '/home/rektide/src/wxt-rolldown/node_modules/.pnpm/[email protected]/node_modules/node-gyp/gyp/gyp_main.py',
│ gyp info spawn args 'binding.gyp',
│ gyp info spawn args '-f',
│ gyp info spawn args 'make',
│ gyp info spawn args '-I',
│ gyp info spawn args '/home/rektide/src/wxt-rolldown/node_modules/.pnpm/[email protected]/node_modules/sharp/src/build/config.gypi',
│ gyp info spawn args '-I',
│ gyp info spawn args '/home/rektide/src/wxt-rolldown/node_modules/.pnpm/[email protected]/node_modules/node-gyp/addon.gypi',
│ gyp info spawn args '-I',
│ gyp info spawn args '/home/rektide/.cache/node-gyp/25.8.0/include/node/common.gypi',
│ gyp info spawn args '-Dlibrary=shared_library',
│ gyp info spawn args '-Dvisibility=default',
│ gyp info spawn args '-Dnode_root_dir=/home/rektide/.cache/node-gyp/25.8.0',
│ gyp info spawn args '-Dnode_gyp_dir=/home/rektide/src/wxt-rolldown/node_modules/.pnpm/[email protected]/node_modules/node-gyp',
│ gyp info spawn args '-Dnode_lib_file=/home/rektide/.cache/node-gyp/25.8.0/<(target_arch)/node.lib',
│ gyp info spawn args '-Dmodule_root_dir=/home/rektide/src/wxt-rolldown/node_modules/.pnpm/[email protected]/node_modules/sharp/src',
│ gyp info spawn args '-Dnode_engine=v8',
│ gyp info spawn args '--depth=.',
│ gyp info spawn args '--no-parallel',
│ gyp info spawn args '--generator-output',
│ gyp info spawn args 'build',
│ gyp info spawn args '-Goutput_dir=.'
│ gyp info spawn args ]
│ <string>:123: SyntaxWarning: invalid escape sequence '\/'
│ Package dependency requirement 'libhwy >= 1.0.5' could not be satisfied.
│ Package 'libhwy' has version '', required version is '>= 1.0.5'
│ Package dependency requirement 'libhwy >= 1.0.5' could not be satisfied.
│ Package 'libhwy' has version '', required version is '>= 1.0.5'
│ gyp: Call to 'PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/usr/local/libdata/pkgconfig:/usr/libdata/pkgconfig" pkg-confi…
│ gyp ERR! configure error
│ gyp ERR! stack Error: `gyp` failed with exit code: 1
│ gyp ERR! stack at ChildProcess.<anonymous> (/home/rektide/src/wxt-rolldown/node_modules/.pnpm/[email protected]/node_modules/node-gyp/lib/c…
│ gyp ERR! stack at ChildProcess.emit (node:events:508:20)
│ gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
│ gyp ERR! System Linux 6.19.0-dirty
│ gyp ERR! command "/home/rektide/.local/share/mise/installs/node/25.8.0/bin/node" "/home/rektide/src/wxt-rolldown/node_modules/.pnpm/node_…
│ gyp ERR! cwd /home/rektide/src/wxt-rolldown/node_modules/.pnpm/[email protected]/node_modules/sharp/src
│ gyp ERR! node -v v25.8.0
│ gyp ERR! node-gyp -v v12.2.0
│ gyp ERR! $npm_package_name sharp
│ gyp ERR! $npm_package_version 0.34.5
│ gyp ERR! not ok
└─ Failed in 754ms at /home/rektide/src/wxt-rolldown/node_modules/.pnpm/[email protected]/node_modules/sharp
 ELIFECYCLE  Command failed with exit code 1.

Activity

  1. lovell commented on Mar 5, 2026

    @lovell
    Owner

    Happy to accept a PR that uses pkg-config --variable pc_path pkg-config to generate a list of directories in the pkgConfigPath function, replacing the hard-coded list, if you're able. (Please target the 0.35 branch.)

    sharp/lib/libvips.js

    Lines 153 to 164 in ff4626d

    const brewPkgConfigPath = spawnSync(
    'which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2',
    spawnSyncOptions
    ).stdout || '';
    return [
    brewPkgConfigPath.trim(),
    process.env.PKG_CONFIG_PATH,
    '/usr/local/lib/pkgconfig',
    '/usr/lib/pkgconfig',
    '/usr/local/libdata/pkgconfig',
    '/usr/libdata/pkgconfig'
    ].filter(Boolean).join(':');

  2. added this to the v0.35.0 milestone on Mar 22, 2026
  3. rektide commented on Apr 21, 2026

    @rektide
    Author

    Thank you! 0.35.0-rc4 works for me, with that #4504 work.

    Apologies for not getting the PR to you. The feedback was good and actionable & I ought to have. Thank you for the helpful code review! Thank you for the commit!

  4. lovell commented on Jun 10, 2026

    @lovell
    Owner

    v0.35.0 now available, thanks again for the suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions