lovell / sharp

High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
https://sharp.pixelplumbing.com
Apache License 2.0
28.41k stars 1.28k forks source link

We set `SHARP_FORCE_GLOBAL_LIBVIPS`, but it's still including its own header files. #4150

Open pnxtm opened 5 days ago

pnxtm commented 5 days ago

Question about an existing feature

What are you trying to achieve?

I noticed that when we are providing env var SHARP_FORCE_GLOBAL_LIBVIPS, it's still linked to downloaded header files and doesn't use globally installed header files. I think this behavior is incorrect, because there might be a difference between header files and compiled library.

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this question

After a successful build, if we open file src/build/sharp-linux-x64.target.mk we can see this:

INCS_Debug := \
...
        -I/home/sam/test/node_modules/sharp/node_modules/@img/sharp-libvips-dev/include \
        -I/home/sam/test/node_modules/sharp/node_modules/@img/sharp-libvips-dev/include/glib-2.0 \

The make commands needs this information to properly link header files , otherwise we got errors like this:

In file included from ../common.cc:13:
/usr/include/vips/vips8:35:10: fatal error: glib-object.h: No such file or directory
   35 | #include <glib-object.h>
      |          ^~~~~~~~~~~~~~~

The above error is because the path /usr/include/glib-2.0 is not included in the search path. The compiler clearly doesn't know where it is, but if we search for it, we can see it is inside /usr/include/glib-2.0.

There is a function (buildSharpLibvipsIncludeDir) inside script sharp/lib/libvips.js that fills the search path inclusion section. I saw the script, it seems providing env var SHARP_FORCE_GLOBAL_LIBVIPS isn't affect the search path at all.

I suggest using the system header files when the user set env var SHARP_FORCE_GLOBAL_LIBVIPS.

Build log npm verbose cli /usr/bin/node /usr/bin/npm npm info using npm@10.7.0 npm info using node@v20.15.0 npm verbose title npm install node-gyp node-addon-api sharp npm verbose argv "install" "--loglevel" "verbose" "--foreground-scripts" "node-gyp" "node-addon-api" "sharp" npm verbose logfile logs-max:10 dir:/home/mostafa/.npm/_logs/2024-07-03T10_25_49_466Z- npm verbose logfile /home/mostafa/.npm/_logs/2024-07-03T10_25_49_466Z-debug-0.log npm http fetch GET 200 https://registry.npmjs.org/node-gyp 766ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/node-addon-api 9ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/sharp 14ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/semver 154ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/detect-libc 158ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-darwin-x64 159ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-darwin-arm64 165ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/semver 172ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-darwin-x64 175ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linux-arm64 178ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linux-x64 177ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linux-arm 194ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linux-s390x 194ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linuxmusl-arm64 185ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/color 210ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-darwin-arm64 207ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linuxmusl-x64 191ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/glob 247ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linux-s390x 97ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linux-arm 109ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linux-arm64 107ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linuxmusl-arm64 91ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linux-x64 102ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linuxmusl-x64 91ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-wasm32 89ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-win32-ia32 81ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-win32-x64 79ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/env-paths 530ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/proc-log 528ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/graceful-fs 557ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/nopt 576ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/which 577ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/tar 588ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/exponential-backoff 618ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/make-fetch-happen 724ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/jackspeak 192ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/path-scurry 193ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/foreground-child 209ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/minipass 209ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/package-json-from-dist 250ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/cacache 248ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/minipass 258ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/minipass-fetch 254ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/negotiator 263ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/minipass 253ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/minizlib 267ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/yallist 284ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/is-lambda 315ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/ssri 335ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/minimatch 353ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/fs-minipass 173ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/promise-retry 349ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/@npmcli%2fagent 366ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/isexe 221ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/minipass-flush 513ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/http-cache-semantics 505ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/abbrev 511ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/chownr 535ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/minipass-pipeline 553ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/mkdirp 552ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/cross-spawn 137ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/lru-cache 157ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/brace-expansion 190ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/@isaacs%2fcliui 196ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/@pkgjs%2fparseargs 202ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/signal-exit 651ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/shebang-command 133ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/path-key 145ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/shebang-regex 119ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/strip-ansi 144ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/string-width 163ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/strip-ansi 162ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/wrap-ansi 164ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/string-width 182ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/wrap-ansi 187ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/emoji-regex 143ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/ansi-styles 159ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/ansi-regex 168ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/is-fullwidth-code-point 185ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/eastasianwidth 193ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/ansi-styles 187ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/emoji-regex 195ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/ansi-regex 195ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/socks-proxy-agent 158ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/http-proxy-agent 170ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/unique-filename 172ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/https-proxy-agent 186ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/agent-base 196ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/minipass-sized 208ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/minipass-collect 212ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/encoding 210ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/@npmcli%2ffs 220ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/err-code 212ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/retry 214ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/p-map 233ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/debug 141ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/debug 153ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/socks 162ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/ms 112ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/aggregate-error 141ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/unique-slug 313ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/balanced-match 146ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/iconv-lite 156ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/safer-buffer 145ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/indent-string 155ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/clean-stack 162ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/color-convert 15ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/@emnapi%2fruntime 20ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/color-string 20ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/tslib 7ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/simple-swizzle 19ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/color-name 25ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/color-name 25ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/is-arrayish 4ms (cache hit) npm http fetch GET 200 https://registry.npmjs.org/ip-address 121ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/smart-buffer 138ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/jsbn 142ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/sprintf-js 143ms (cache revalidated) npm http fetch GET 200 https://registry.npmjs.org/imurmurhash 139ms (cache revalidated) npm verbose reify failed optional dependency /tmp/test2/node_modules/@img/sharp-win32-x64 npm verbose reify failed optional dependency /tmp/test2/node_modules/@img/sharp-win32-ia32 npm verbose reify failed optional dependency /tmp/test2/node_modules/@img/sharp-wasm32 npm verbose reify failed optional dependency /tmp/test2/node_modules/@emnapi/runtime npm verbose reify failed optional dependency /tmp/test2/node_modules/tslib npm verbose reify failed optional dependency /tmp/test2/node_modules/@img/sharp-linuxmusl-x64 npm verbose reify failed optional dependency /tmp/test2/node_modules/@img/sharp-linuxmusl-arm64 npm verbose reify failed optional dependency /tmp/test2/node_modules/@img/sharp-linux-s390x npm verbose reify failed optional dependency /tmp/test2/node_modules/@img/sharp-linux-arm64 npm verbose reify failed optional dependency /tmp/test2/node_modules/@img/sharp-linux-arm npm verbose reify failed optional dependency /tmp/test2/node_modules/@img/sharp-libvips-linuxmusl-x64 npm verbose reify failed optional dependency /tmp/test2/node_modules/@img/sharp-libvips-linuxmusl-arm64 npm verbose reify failed optional dependency /tmp/test2/node_modules/@img/sharp-libvips-linux-s390x npm verbose reify failed optional dependency /tmp/test2/node_modules/@img/sharp-libvips-linux-arm64 npm verbose reify failed optional dependency /tmp/test2/node_modules/@img/sharp-libvips-linux-arm npm verbose reify failed optional dependency /tmp/test2/node_modules/@img/sharp-libvips-darwin-x64 npm verbose reify failed optional dependency /tmp/test2/node_modules/@img/sharp-libvips-darwin-arm64 npm verbose reify failed optional dependency /tmp/test2/node_modules/@img/sharp-darwin-x64 npm verbose reify failed optional dependency /tmp/test2/node_modules/@img/sharp-darwin-arm64 npm info run sharp@0.33.4 install node_modules/sharp node install/check > sharp@0.33.4 install > node install/check sharp: Detected SHARP_FORCE_GLOBAL_LIBVIPS, skipping search for globally-installed libvips sharp: Detected globally-installed libvips v8.15.2 sharp: Attempting to build from source via node-gyp sharp: Found node-addon-api sharp: Found node-gyp version 10.1.0 sharp: See https://sharp.pixelplumbing.com/install#building-from-source gyp info it worked if it ends with ok gyp verb cli [ gyp verb cli '/usr/bin/node', gyp verb cli '/tmp/test2/node_modules/.bin/node-gyp', gyp verb cli 'rebuild', gyp verb cli '--directory=src' gyp verb cli ] gyp info using node-gyp@10.1.0 gyp info using node@20.15.0 | linux | x64 gyp info chdir src gyp verb clean removing "build" directory gyp verb find Python Python is not set from command line or npm configuration gyp verb find Python Python is not set from environment variable PYTHON gyp verb find Python checking if "python3" can be used gyp verb find Python - executing "python3" to get executable path gyp verb find Python - executable path is "/usr/bin/python3" gyp verb find Python - executing "/usr/bin/python3" to get version gyp verb find Python - version is "3.9.2" gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3" gyp verb get node dir no --target version specified, falling back to host node version: 20.15.0 gyp verb install input version string "20.15.0" gyp verb install installing version: 20.15.0 gyp verb install --ensure was passed, so won't reinstall if already installed gyp verb install version is already installed, need to check "installVersion" gyp verb got "installVersion" 11 gyp verb needs "installVersion" 11 gyp verb install version is good gyp verb get node dir target node version installed: 20.15.0 gyp verb build dir attempting to create "build" dir: /tmp/test2/node_modules/sharp/src/build gyp verb build dir "build" dir needed to be created? Yes gyp verb build/config.gypi creating config file gyp verb build/config.gypi writing out config file: /tmp/test2/node_modules/sharp/src/build/config.gypi gyp verb config.gypi checking for gypi file: /tmp/test2/node_modules/sharp/src/config.gypi gyp verb common.gypi checking for gypi file: /tmp/test2/node_modules/sharp/src/common.gypi gyp verb gyp gyp format was not specified; forcing "make" gyp info spawn /usr/bin/python3 gyp info spawn args [ gyp info spawn args '/tmp/test2/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 '/tmp/test2/node_modules/sharp/src/build/config.gypi', gyp info spawn args '-I', gyp info spawn args '/tmp/test2/node_modules/node-gyp/addon.gypi', gyp info spawn args '-I', gyp info spawn args '/home/mostafa/.cache/node-gyp/20.15.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/mostafa/.cache/node-gyp/20.15.0', gyp info spawn args '-Dnode_gyp_dir=/tmp/test2/node_modules/node-gyp', gyp info spawn args '-Dnode_lib_file=/home/mostafa/.cache/node-gyp/20.15.0/<(target_arch)/node.lib', gyp info spawn args '-Dmodule_root_dir=/tmp/test2/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 ] gyp verb build type Release gyp verb architecture x64 gyp verb node dev dir /home/mostafa/.cache/node-gyp/20.15.0 gyp verb python /usr/bin/python3 gyp verb `which` succeeded for `make` /usr/bin/make gyp verb bin symlinks created symlink to "/usr/bin/python3" in "/tmp/test2/node_modules/sharp/src/build/node_gyp_bins" and added to PATH gyp info spawn make gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ] make: Entering directory '/tmp/test2/node_modules/sharp/src/build' cc -o Release/obj.target/nothing/../../node-addon-api/nothing.o ../../../node-addon-api/nothing.c '-DNODE_GYP_MODULE_NAME=nothing' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' -I/home/mostafa/.cache/node-gyp/20.15.0/include/node -I/home/mostafa/.cache/node-gyp/20.15.0/src -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/config -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/openssl/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/uv/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/zlib -I/home/mostafa/.cache/node-gyp/20.15.0/deps/v8/include -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer -MMD -MF ./Release/.deps/Release/obj.target/nothing/../../node-addon-api/nothing.o.d.raw -c rm -f Release/obj.target/../../node-addon-api/nothing.a Release/obj.target/../../node-addon-api/nothing.a.ar-file-list; mkdir -p `dirname Release/obj.target/../../node-addon-api/nothing.a` ar crs Release/obj.target/../../node-addon-api/nothing.a @Release/obj.target/../../node-addon-api/nothing.a.ar-file-list ln -f "Release/obj.target/../../node-addon-api/nothing.a" "Release/nothing.a" 2>/dev/null || (rm -rf "Release/nothing.a" && cp -af "Release/obj.target/../../node-addon-api/nothing.a" "Release/nothing.a") touch Release/obj.target/libvips-cpp.stamp g++ -o Release/obj.target/sharp-linux-x64/common.o ../common.cc '-DNODE_GYP_MODULE_NAME=sharp-linux-x64' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DNAPI_VERSION=9' '-DNODE_ADDON_API_DISABLE_DEPRECATED' '-DNODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS' '-DBUILDING_NODE_EXTENSION' -I/home/mostafa/.cache/node-gyp/20.15.0/include/node -I/home/mostafa/.cache/node-gyp/20.15.0/src -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/config -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/openssl/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/uv/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/zlib -I/home/mostafa/.cache/node-gyp/20.15.0/deps/v8/include -I../../../node-addon-api -I../. -I/glib-2.0 -I/tmp/test2/node_modules/@img/sharp-libvips-linux-x64/lib/glib-2.0/include -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++17 -std=c++0x -fexceptions -Wall -Os -MMD -MF ./Release/.deps/Release/obj.target/sharp-linux-x64/common.o.d.raw -c In file included from ../common.cc:13: /usr/local/include/vips/vips8:35:10: fatal error: glib-object.h: No such file or directory 35 | #include | ^~~~~~~~~~~~~~~ compilation terminated. make: *** [sharp-linux-x64.target.mk:137: Release/obj.target/sharp-linux-x64/common.o] Error 1 make: Leaving directory '/tmp/test2/node_modules/sharp/src/build' gyp ERR! build error gyp ERR! stack Error: `make` failed with exit code: 2 gyp ERR! stack at ChildProcess. (/tmp/test2/node_modules/node-gyp/lib/build.js:209:23) gyp ERR! System Linux 4.9.0-13-amd64 gyp ERR! command "/usr/bin/node" "/tmp/test2/node_modules/.bin/node-gyp" "rebuild" "--directory=src" gyp ERR! cwd /tmp/test2/node_modules/sharp/src gyp ERR! node -v v20.15.0 gyp ERR! node-gyp -v v10.1.0 gyp ERR! not ok npm info run sharp@0.33.4 install { code: 1, signal: null } npm verbose stack Error: command failed npm verbose stack at ChildProcess. (/usr/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:53:27) npm verbose stack at ChildProcess.emit (node:events:519:28) npm verbose stack at maybeClose (node:internal/child_process:1105:16) npm verbose stack at ChildProcess._handle.onexit (node:internal/child_process:305:5) npm verbose pkgid sharp@0.33.4 npm verbose cwd /tmp/test2 npm verbose Linux 4.9.0-13-amd64 npm verbose node v20.15.0 npm verbose npm v10.7.0 npm error code 1 npm error path /tmp/test2/node_modules/sharp npm error command failed npm error command sh -c node install/check npm verbose exit 1 npm verbose code 1 npm error A complete log of this run can be found in: /home/mostafa/.npm/_logs/2024-07-03T10_25_49_466Z-debug-0.log

Regards.

lovell commented 5 days ago

Are you sure you're using a globally-installed libvips?

I ask as, if you follow the use_global_libvips logic in binding.gyp, you'll see that the sharp_libvips_include_dir variable (containing the output of buildSharpLibvipsIncludeDir) is only used when use_global_libvips is false.

Please ensure you've installed all of the additional dependencies for building from source as documented.

https://sharp.pixelplumbing.com/install#building-from-source

If you're still having problems, please provide the complete output of running npm install --verbose --foreground-scripts sharp in an empty directory.

pnxtm commented 5 days ago

Are you sure you're using a globally-installed libvips?

Thanks for your quick reply. I have included build log. This is the section you requested:

sharp: Detected SHARP_FORCE_GLOBAL_LIBVIPS, skipping search for globally-installed libvips
sharp: Detected globally-installed libvips v8.15.2

From build log you can see the included path is incorrect (-I/glib-2.0). This is the content of build/sharp-linux-x64.target.mk:

INCS_Debug := \
        -I/home/mostafa/.cache/node-gyp/20.15.0/include/node \
...
        -I$(srcdir)/../../node-addon-api \
        -I$(srcdir)/. \
        -I/glib-2.0 \
        -I/tmp/test2/node_modules/@img/sharp-libvips-linux-x64/lib/glib-2.0/include
pnxtm commented 5 days ago

Thanks for your reply, I found the solution. We must provide OS (uppercase) instead of os (as entered in binding.gyp):

SHARP_FORCE_GLOBAL_LIBVIPS=true npm install --OS=linux  node-gyp node-addon-api sharp ...
lovell commented 5 days ago

I'm unsure why the capitalisation of an npm flag would fix this? Could it be that the solution was to also install node-gyp and node-addon-api (as documented)?

pnxtm commented 2 days ago

I'm unsure why the capitalisation of an npm flag would fix this? Could it be that the solution was to also install node-gyp and node-addon-api (as documented)?

I tried using a lowercase OS command and got the same error.

SHARP_FORCE_GLOBAL_LIBVIPS=true npm install --verbose --os=linux node-gyp node-addon-api sharp
lovell commented 2 days ago

Running npm --OS=linux is equivalent to running npm --save-optional --save linux so what you're doing is installing a package called linux and adding it to your dependencies. I suspect this is not what you want.

If you're still having problems, please provide the complete output of running the following commands in an empty directory:

npm install node-gyp node-addon-api
npm install --verbose --foreground-scripts sharp

Please don't set SHARP_FORCE_GLOBAL_LIBVIPS, and I want to see all of the output.

pnxtm commented 2 days ago

Running npm --OS=linux is equivalent to running npm --save-optional --save linux so what you're doing is installing a package called linux and adding it to your dependencies. I suspect this is not what you want.

You are right.

Log output:

npm verbose cli /usr/bin/node /usr/bin/npm
npm info using npm@10.7.0
npm info using node@v20.15.0
npm verbose title npm install sharp
npm verbose argv "install" "--loglevel" "verbose" "--foreground-scripts" "sharp"
npm verbose logfile logs-max:10 dir:/home/mostafa/.npm/_logs/2024-07-06T09_11_00_380Z-
npm verbose logfile /home/mostafa/.npm/_logs/2024-07-06T09_11_00_380Z-debug-0.log
npm http fetch GET 200 https://registry.npmjs.org/sharp 50ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/detect-libc 84ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-darwin-arm64 85ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-darwin-x64 89ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linux-arm 90ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/color 96ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linux-s390x 95ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linux-x64 96ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linux-arm64 100ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linuxmusl-x64 99ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linux-arm64 100ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linux-arm 103ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linux-s390x 104ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linuxmusl-x64 101ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linuxmusl-arm64 104ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-wasm32 105ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-win32-ia32 106ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-linux-x64 115ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-win32-x64 111ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-darwin-x64 125ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-libvips-linuxmusl-arm64 124ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@img%2fsharp-darwin-arm64 131ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/@emnapi%2fruntime 13ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/color-string 15ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/tslib 6ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/simple-swizzle 8ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/is-arrayish 8ms (cache hit)
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/@img/sharp-win32-x64
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/@img/sharp-win32-ia32
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/@img/sharp-wasm32
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/@emnapi/runtime
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/tslib
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/@img/sharp-linuxmusl-x64
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/@img/sharp-linuxmusl-arm64
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/@img/sharp-linux-s390x
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/@img/sharp-linux-arm64
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/@img/sharp-linux-arm
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/@img/sharp-libvips-linuxmusl-x64
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/@img/sharp-libvips-linuxmusl-arm64
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/@img/sharp-libvips-linux-s390x
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/@img/sharp-libvips-linux-arm64
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/@img/sharp-libvips-linux-arm
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/@img/sharp-libvips-darwin-x64
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/@img/sharp-libvips-darwin-arm64
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/@img/sharp-darwin-x64
npm verbose reify failed optional dependency /home/mostafa/sam/yocto/test/node_modules/@img/sharp-darwin-arm64
npm info run sharp@0.33.4 install node_modules/sharp node install/check

> sharp@0.33.4 install
> node install/check

sharp: Detected globally-installed libvips v8.15.2
sharp: Attempting to build from source via node-gyp
sharp: Found node-addon-api 
sharp: Found node-gyp version 10.1.0
sharp: See https://sharp.pixelplumbing.com/install#building-from-source
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli '/usr/bin/node',
gyp verb cli '/home/mostafa/sam/yocto/test/node_modules/.bin/node-gyp',
gyp verb cli 'rebuild',
gyp verb cli '--directory=src'
gyp verb cli ]
gyp info using node-gyp@10.1.0
gyp info using node@20.15.0 | linux | x64
gyp info chdir src
gyp verb clean removing "build" directory
gyp verb find Python Python is not set from command line or npm configuration
gyp verb find Python Python is not set from environment variable PYTHON
gyp verb find Python checking if "python3" can be used
gyp verb find Python - executing "python3" to get executable path
gyp verb find Python - executable path is "/usr/bin/python3"
gyp verb find Python - executing "/usr/bin/python3" to get version
gyp verb find Python - version is "3.9.2"
gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3"
gyp verb get node dir no --target version specified, falling back to host node version: 20.15.0

gyp verb install input version string "20.15.0"
gyp verb install installing version: 20.15.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 11
gyp verb needs "installVersion" 11
gyp verb install version is good
gyp verb get node dir target node version installed: 20.15.0
gyp verb build dir attempting to create "build" dir: /home/mostafa/sam/yocto/test/node_modules/sharp/src/build
gyp verb build dir "build" dir needed to be created? Yes
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: /home/mostafa/sam/yocto/test/node_modules/sharp/src/build/config.gypi
gyp verb config.gypi checking for gypi file: /home/mostafa/sam/yocto/test/node_modules/sharp/src/config.gypi
gyp verb common.gypi checking for gypi file: /home/mostafa/sam/yocto/test/node_modules/sharp/src/common.gypi
gyp verb gyp gyp format was not specified; forcing "make"
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args '/home/mostafa/sam/yocto/test/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/mostafa/sam/yocto/test/node_modules/sharp/src/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/mostafa/sam/yocto/test/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/mostafa/.cache/node-gyp/20.15.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/mostafa/.cache/node-gyp/20.15.0',
gyp info spawn args '-Dnode_gyp_dir=/home/mostafa/sam/yocto/test/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/home/mostafa/.cache/node-gyp/20.15.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/home/mostafa/sam/yocto/test/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 ]
gyp verb build type Release
gyp verb architecture x64
gyp verb node dev dir /home/mostafa/.cache/node-gyp/20.15.0
gyp verb python /usr/bin/python3
gyp verb `which` succeeded for `make` /usr/bin/make
gyp verb bin symlinks created symlink to "/usr/bin/python3" in "/home/mostafa/sam/yocto/test/node_modules/sharp/src/build/node_gyp_bins" and added to PATH
gyp info spawn make
gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/mostafa/sam/yocto/test/node_modules/sharp/src/build'
  cc -o Release/obj.target/nothing/../../node-addon-api/nothing.o ../../../node-addon-api/nothing.c '-DNODE_GYP_MODULE_NAME=nothing' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' -I/home/mostafa/.cache/node-gyp/20.15.0/include/node -I/home/mostafa/.cache/node-gyp/20.15.0/src -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/config -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/openssl/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/uv/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/zlib -I/home/mostafa/.cache/node-gyp/20.15.0/deps/v8/include  -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer  -MMD -MF ./Release/.deps/Release/obj.target/nothing/../../node-addon-api/nothing.o.d.raw   -c
rm -f Release/obj.target/../../node-addon-api/nothing.a Release/obj.target/../../node-addon-api/nothing.a.ar-file-list; mkdir -p `dirname Release/obj.target/../../node-addon-api/nothing.a`
ar crs Release/obj.target/../../node-addon-api/nothing.a @Release/obj.target/../../node-addon-api/nothing.a.ar-file-list
  ln -f "Release/obj.target/../../node-addon-api/nothing.a" "Release/nothing.a" 2>/dev/null || (rm -rf "Release/nothing.a" && cp -af "Release/obj.target/../../node-addon-api/nothing.a" "Release/nothing.a")
  touch Release/obj.target/libvips-cpp.stamp
  g++ -o Release/obj.target/sharp-linux-x64/common.o ../common.cc '-DNODE_GYP_MODULE_NAME=sharp-linux-x64' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DNAPI_VERSION=9' '-DNODE_ADDON_API_DISABLE_DEPRECATED' '-DNODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS' '-DSHARP_USE_GLOBAL_LIBVIPS' '-DBUILDING_NODE_EXTENSION' -I/home/mostafa/.cache/node-gyp/20.15.0/include/node -I/home/mostafa/.cache/node-gyp/20.15.0/src -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/config -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/openssl/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/uv/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/zlib -I/home/mostafa/.cache/node-gyp/20.15.0/deps/v8/include -I../../../node-addon-api -I/usr/local/include -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/x86_64-linux-gnu -I/usr/include/librsvg-2.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/lib/x86_64-linux-gnu/hdf5/serial/include -I/usr/include/OpenEXR -I/usr/include/openjpeg-2.4 -I/usr/include/orc-0.4 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include  -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++17 -std=c++0x -fexceptions -Wall -Os -MMD -MF ./Release/.deps/Release/obj.target/sharp-linux-x64/common.o.d.raw   -c
  g++ -o Release/obj.target/sharp-linux-x64/metadata.o ../metadata.cc '-DNODE_GYP_MODULE_NAME=sharp-linux-x64' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DNAPI_VERSION=9' '-DNODE_ADDON_API_DISABLE_DEPRECATED' '-DNODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS' '-DSHARP_USE_GLOBAL_LIBVIPS' '-DBUILDING_NODE_EXTENSION' -I/home/mostafa/.cache/node-gyp/20.15.0/include/node -I/home/mostafa/.cache/node-gyp/20.15.0/src -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/config -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/openssl/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/uv/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/zlib -I/home/mostafa/.cache/node-gyp/20.15.0/deps/v8/include -I../../../node-addon-api -I/usr/local/include -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/x86_64-linux-gnu -I/usr/include/librsvg-2.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/lib/x86_64-linux-gnu/hdf5/serial/include -I/usr/include/OpenEXR -I/usr/include/openjpeg-2.4 -I/usr/include/orc-0.4 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include  -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++17 -std=c++0x -fexceptions -Wall -Os -MMD -MF ./Release/.deps/Release/obj.target/sharp-linux-x64/metadata.o.d.raw   -c
  g++ -o Release/obj.target/sharp-linux-x64/stats.o ../stats.cc '-DNODE_GYP_MODULE_NAME=sharp-linux-x64' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DNAPI_VERSION=9' '-DNODE_ADDON_API_DISABLE_DEPRECATED' '-DNODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS' '-DSHARP_USE_GLOBAL_LIBVIPS' '-DBUILDING_NODE_EXTENSION' -I/home/mostafa/.cache/node-gyp/20.15.0/include/node -I/home/mostafa/.cache/node-gyp/20.15.0/src -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/config -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/openssl/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/uv/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/zlib -I/home/mostafa/.cache/node-gyp/20.15.0/deps/v8/include -I../../../node-addon-api -I/usr/local/include -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/x86_64-linux-gnu -I/usr/include/librsvg-2.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/lib/x86_64-linux-gnu/hdf5/serial/include -I/usr/include/OpenEXR -I/usr/include/openjpeg-2.4 -I/usr/include/orc-0.4 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include  -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++17 -std=c++0x -fexceptions -Wall -Os -MMD -MF ./Release/.deps/Release/obj.target/sharp-linux-x64/stats.o.d.raw   -c
  g++ -o Release/obj.target/sharp-linux-x64/operations.o ../operations.cc '-DNODE_GYP_MODULE_NAME=sharp-linux-x64' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DNAPI_VERSION=9' '-DNODE_ADDON_API_DISABLE_DEPRECATED' '-DNODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS' '-DSHARP_USE_GLOBAL_LIBVIPS' '-DBUILDING_NODE_EXTENSION' -I/home/mostafa/.cache/node-gyp/20.15.0/include/node -I/home/mostafa/.cache/node-gyp/20.15.0/src -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/config -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/openssl/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/uv/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/zlib -I/home/mostafa/.cache/node-gyp/20.15.0/deps/v8/include -I../../../node-addon-api -I/usr/local/include -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/x86_64-linux-gnu -I/usr/include/librsvg-2.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/lib/x86_64-linux-gnu/hdf5/serial/include -I/usr/include/OpenEXR -I/usr/include/openjpeg-2.4 -I/usr/include/orc-0.4 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include  -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++17 -std=c++0x -fexceptions -Wall -Os -MMD -MF ./Release/.deps/Release/obj.target/sharp-linux-x64/operations.o.d.raw   -c
  g++ -o Release/obj.target/sharp-linux-x64/pipeline.o ../pipeline.cc '-DNODE_GYP_MODULE_NAME=sharp-linux-x64' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DNAPI_VERSION=9' '-DNODE_ADDON_API_DISABLE_DEPRECATED' '-DNODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS' '-DSHARP_USE_GLOBAL_LIBVIPS' '-DBUILDING_NODE_EXTENSION' -I/home/mostafa/.cache/node-gyp/20.15.0/include/node -I/home/mostafa/.cache/node-gyp/20.15.0/src -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/config -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/openssl/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/uv/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/zlib -I/home/mostafa/.cache/node-gyp/20.15.0/deps/v8/include -I../../../node-addon-api -I/usr/local/include -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/x86_64-linux-gnu -I/usr/include/librsvg-2.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/lib/x86_64-linux-gnu/hdf5/serial/include -I/usr/include/OpenEXR -I/usr/include/openjpeg-2.4 -I/usr/include/orc-0.4 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include  -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++17 -std=c++0x -fexceptions -Wall -Os -MMD -MF ./Release/.deps/Release/obj.target/sharp-linux-x64/pipeline.o.d.raw   -c
  g++ -o Release/obj.target/sharp-linux-x64/utilities.o ../utilities.cc '-DNODE_GYP_MODULE_NAME=sharp-linux-x64' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DNAPI_VERSION=9' '-DNODE_ADDON_API_DISABLE_DEPRECATED' '-DNODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS' '-DSHARP_USE_GLOBAL_LIBVIPS' '-DBUILDING_NODE_EXTENSION' -I/home/mostafa/.cache/node-gyp/20.15.0/include/node -I/home/mostafa/.cache/node-gyp/20.15.0/src -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/config -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/openssl/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/uv/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/zlib -I/home/mostafa/.cache/node-gyp/20.15.0/deps/v8/include -I../../../node-addon-api -I/usr/local/include -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/x86_64-linux-gnu -I/usr/include/librsvg-2.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/lib/x86_64-linux-gnu/hdf5/serial/include -I/usr/include/OpenEXR -I/usr/include/openjpeg-2.4 -I/usr/include/orc-0.4 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include  -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++17 -std=c++0x -fexceptions -Wall -Os -MMD -MF ./Release/.deps/Release/obj.target/sharp-linux-x64/utilities.o.d.raw   -c
  g++ -o Release/obj.target/sharp-linux-x64/sharp.o ../sharp.cc '-DNODE_GYP_MODULE_NAME=sharp-linux-x64' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DNAPI_VERSION=9' '-DNODE_ADDON_API_DISABLE_DEPRECATED' '-DNODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS' '-DSHARP_USE_GLOBAL_LIBVIPS' '-DBUILDING_NODE_EXTENSION' -I/home/mostafa/.cache/node-gyp/20.15.0/include/node -I/home/mostafa/.cache/node-gyp/20.15.0/src -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/config -I/home/mostafa/.cache/node-gyp/20.15.0/deps/openssl/openssl/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/uv/include -I/home/mostafa/.cache/node-gyp/20.15.0/deps/zlib -I/home/mostafa/.cache/node-gyp/20.15.0/deps/v8/include -I../../../node-addon-api -I/usr/local/include -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/x86_64-linux-gnu -I/usr/include/librsvg-2.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/lib/x86_64-linux-gnu/hdf5/serial/include -I/usr/include/OpenEXR -I/usr/include/openjpeg-2.4 -I/usr/include/orc-0.4 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include  -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++17 -std=c++0x -fexceptions -Wall -Os -MMD -MF ./Release/.deps/Release/obj.target/sharp-linux-x64/sharp.o.d.raw   -c
  g++ -o Release/obj.target/sharp-linux-x64.node -shared -pthread -rdynamic -m64  -Wl,-soname=sharp-linux-x64.node -Wl,--start-group Release/obj.target/sharp-linux-x64/common.o Release/obj.target/sharp-linux-x64/metadata.o Release/obj.target/sharp-linux-x64/stats.o Release/obj.target/sharp-linux-x64/operations.o Release/obj.target/sharp-linux-x64/pipeline.o Release/obj.target/sharp-linux-x64/utilities.o Release/obj.target/sharp-linux-x64/sharp.o Release/obj.target/../../node-addon-api/nothing.a -Wl,--end-group -L/usr/local/lib/x86_64-linux-gnu -lvips-cpp -lvips -lgio-2.0 -lgobject-2.0 -lglib-2.0
  ln -f "Release/obj.target/sharp-linux-x64.node" "Release/sharp-linux-x64.node" 2>/dev/null || (rm -rf "Release/sharp-linux-x64.node" && cp -af "Release/obj.target/sharp-linux-x64.node" "Release/sharp-linux-x64.node")
  touch Release/obj.target/copy-dll.stamp
make: Leaving directory '/home/mostafa/sam/yocto/test/node_modules/sharp/src/build'
gyp info ok 
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 779ms
npm info run sharp@0.33.4 install { code: 0, signal: null }

added 8 packages, and audited 112 packages in 19s

17 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
npm verbose exit 0
npm info ok
lovell commented 5 hours ago

Thanks, it looks like this succeeded in building sharp from source against a globally-installed libvips and the -I include paths appear to be correct and as-expected. Does this solve your initial problem?