withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
44.99k stars 2.35k forks source link

Astro Image has sharp issue with pnpm #9416

Closed RogierdeRuijter closed 8 months ago

RogierdeRuijter commented 8 months ago

Astro Info

Astro                    v4.0.4
Node                     v18.19.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Using Astro Image in combination with sharp and pnpm results in an installation error: fatal error: 'vips/vips8' file not found. pnpm version: 8.10.0

What's the expected result?

Succesful installation

Link to Minimal Reproducible Example

https://github.com/RogierdeRuijter/astro-sharp-issue

Participation

Princesseuh commented 8 months ago

Your reproduction works perfectly fine for me. I cloned it, ran pnpm install, and everything worked as expected.

Do you have more details?

RogierdeRuijter commented 8 months ago

Uhmm really strange.

This is the full error I get:

node_modules/.pnpm/sharp@0.32.6/node_modules/sharp: Running install script, failed in 17.7s
.../sharp@0.32.6/node_modules/sharp install$ (node install/libvips && node install/dll-copy && p…
sharp: Detected globally-installed libvips v8.15.0
sharp: Building from source via node-gyp
gyp info it worked if it ends with ok
gyp info using node-gyp@9.4.0
gyp info using node@18.19.0 | darwin | arm64
gyp info find Python using Python version 3.11.6 found at "/opt/homebrew/opt/python@3.11/bin/p…
gyp info spawn /opt/homebrew/opt/python@3.11/bin/python3.11
gyp info spawn args [
gyp info spawn args   '/Users/r.de.ruijter/.cache/node/corepack/pnpm/8.10.0/dist/node_modules/…
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   '/Users/r.de.ruijter/Documents/werk/experimenten/astro/sharp/node_module…
gyp info spawn args   '-I',
gyp info spawn args   '/Users/r.de.ruijter/.cache/node/corepack/pnpm/8.10.0/dist/node_modules/…
gyp info spawn args   '-I',
gyp info spawn args   '/Users/r.de.ruijter/Library/Caches/node-gyp/18.19.0/include/node/common…
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/r.de.ruijter/Library/Caches/node-gyp/18.19.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/r.de.ruijter/.cache/node/corepack/pnpm/8.10.0/dis…
gyp info spawn args   '-Dnode_lib_file=/Users/r.de.ruijter/Library/Caches/node-gyp/18.19.0/<(t…
gyp info spawn args   '-Dmodule_root_dir=/Users/r.de.ruijter/Documents/werk/experimenten/astro…
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 ]
Package libarchive was not found in the pkg-config search path.
Perhaps you should add the directory containing `libarchive.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libarchive', required by 'vips', not found
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CC(target) Release/obj.target/nothing/../../../node-addon-api@6.1.0/node_modules/node-addon-…
  LIBTOOL-STATIC Release/nothing.a
warning: /Library/Developer/CommandLineTools/usr/bin/libtool: archive library: Release/nothing…
  TOUCH Release/obj.target/libvips-cpp.stamp
  CXX(target) Release/obj.target/sharp-darwin-arm64v8/src/common.o
../src/common.cc:13:10: fatal error: 'vips/vips8' file not found
#include <vips/vips8>
         ^~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/sharp-darwin-arm64v8/src/common.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/r.de.ruijter/.cache/node/corepack/pnpm/8.10.…
gyp ERR! stack     at ChildProcess.emit (node:events:517:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:292:12)
gyp ERR! System Darwin 23.2.0
gyp ERR! command "/Users/r.de.ruijter/.nvm/versions/node/v18.19.0/bin/node" "/Users/r.de.ruijt…
gyp ERR! cwd /Users/r.de.ruijter/Documents/werk/experimenten/astro/sharp/node_modules/.pnpm/sh…
gyp ERR! node -v v18.19.0
gyp ERR! node-gyp -v v9.4.0
gyp ERR! not ok

Does this give you an idea?

bis0072 commented 8 months ago

Delete node_modules and pnpm-lock.yaml file, pnpm store prune and fresh install. This could help I think.

RogierdeRuijter commented 8 months ago

Haven't found the problem yet, but I am pretty sure now this is not an astro issue, I'll close this issue for now, my bad! Ill report here if I find a solution for future reference.

RogierdeRuijter commented 8 months ago

I uninstalling the vips library that was installed with homebrew, this did the trick. brew uninstall vips