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
29.1k stars 1.29k forks source link

npm install sharp fails #40

Closed motiooon closed 10 years ago

motiooon commented 10 years ago

$ npm install sharp npm http GET https://registry.npmjs.org/sharp npm http 304 https://registry.npmjs.org/sharp npm http GET https://registry.npmjs.org/nan npm http 304 https://registry.npmjs.org/nan

sharp@0.4.2 install /Users/gabrielbaciu/projects/node-image-processing/node_modules/sharp node-gyp rebuild

CXX(target) Release/obj.target/sharp/src/sharp.o ../src/sharp.cc:6:10: fatal error: 'vips/vips.h' file not found

include <vips/vips.h>

     ^

1 error generated. make: *\ [Release/obj.target/sharp/src/sharp.o] Error 1 gyp ERR! build error gyp ERR! stack Error: make failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23) gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:807:12) gyp ERR! System Darwin 13.2.0 gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /Users/gabrielbaciu/projects/node-image-processing/node_modules/sharp gyp ERR! node -v v0.10.28 gyp ERR! node-gyp -v v0.13.0 gyp ERR! not ok npm ERR! sharp@0.4.2 install: node-gyp rebuild npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the sharp@0.4.2 install script. npm ERR! This is most likely a problem with the sharp package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-gyp rebuild npm ERR! You can get their info via: npm ERR! npm owner ls sharp npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 13.2.0 npm ERR! command "node" "/usr/local/bin/npm" "install" "sharp" npm ERR! cwd /Users/gabrielbaciu/projects/node-image-processing npm ERR! node -v v0.10.28 npm ERR! npm -v 1.4.9 npm ERR! code ELIFECYCLE npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /Users/gabrielbaciu/projects/node-image-processing/npm-debug.log npm ERR! not ok code 0

lovell commented 10 years ago

Hi Gabriel, it looks like you're using a Mac. Did you install vips via homebrew?

What does running vips --version at the command line display?

motiooon commented 10 years ago

yes i did $ vips --version vips-7.38.5-Mon May 26 13:00:32 EDT 2014

lovell commented 10 years ago

Perfect, thanks. What does pkg-config --libs vips display? (This is how the build process "discovers" where libvips is installed - see https://github.com/lovell/sharp/blob/master/binding.gyp#L6 for context.)

motiooon commented 10 years ago

pkg-config --libs vips -L/usr/local/Cellar/vips/7.38.5/lib -L/usr/local/Cellar/graphicsmagick/1.3.19_1/lib -L/usr/local/Cellar/libpng/1.6.10/lib -L/usr/local/Cellar/libtiff/4.0.3/lib -L/usr/local/Cellar/glib/2.40.0_1/lib -L/usr/local/opt/gettext/lib -L/usr/local/Cellar/freetype/2.5.3_1/lib -L/usr/local/Cellar/fontconfig/2.11.1/lib -L/usr/local/Cellar/glib/2.40.0_1/lib -L/usr/local/opt/gettext/lib -L/usr/local/Cellar/pango/1.36.3/lib -L/usr/local/Cellar/fftw/3.3.4/lib -L/usr/local/Cellar/orc/0.4.19/lib -L/usr/local/Cellar/little-cms/1.19/lib -L/usr/local/Cellar/webp/0.4.0_1/lib -L/usr/local/Cellar/libexif/0.6.21/lib -L/usr/local/Cellar/glib/2.40.0_1/lib -L/usr/local/Cellar/fftw/3.3.4/lib -L/usr/local/Cellar/graphicsmagick/1.3.19_1/lib -L/usr/local/Cellar/orc/0.4.19/lib -L/usr/local/Cellar/little-cms/1.19/lib -L/usr/local/Cellar/webp/0.4.0_1/lib -L/usr/local/Cellar/pango/1.36.3/lib -L/usr/local/Cellar/glib/2.40.0_1/lib -L/usr/local/opt/gettext/lib -L/usr/local/Cellar/fontconfig/2.11.1/lib -L/usr/local/Cellar/freetype/2.5.3_1/lib -L/usr/local/Cellar/libtiff/4.0.3/lib -L/usr/local/Cellar/libpng/1.6.10/lib -L/usr/local/Cellar/libexif/0.6.21/lib -lvips -lGraphicsMagick -lpng16 -ltiff -lz -ljpeg -lgmodule-2.0 -lxml2 -lgobject-2.0 -lglib-2.0 -lintl -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lintl -lfontconfig -lfreetype -lfftw3 -lorc-0.4 -llcms -lwebp -lexif -lm -lstdc++ -lxml2 -lgmodule-2.0 -lfftw3 -lGraphicsMagick -lorc-0.4 -llcms -lwebp -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lintl -lfontconfig -lfreetype -ltiff -lpng16 -lexif

lovell commented 10 years ago

Thanks @motiooon. I won't have access to a Mac until later tomorrow to confirm, but based on that output I believe the build process should be able to find vips/vips.h at the location /usr/local/Cellar/vips/7.38.5/lib/vips/vips.h.

What does sudo find / -name vips.h display?

motiooon commented 10 years ago

$ sudo find / -name vips.h Password: find: /dev/fd/3: Not a directory find: /dev/fd/4: Not a directory

motiooon commented 10 years ago

Actually:

$ sudo find / -name vips.h Password: find: /dev/fd/3: Not a directory find: /dev/fd/4: Not a directory /usr/local/Cellar/vips/7.38.5/include/vips/vips.h

lovell commented 10 years ago

Thank you, this has something to do with include paths (lib vs include). I'll see if I can reproduce this on a clean-ish OS X Mavericks 10.9.3 (Darwin 13.2.0) machine tomorrow afternoon.

All I can suggest in the meantime is to brew uninstall vips then force install again using brew install --force homebrew/science/vips --with-webp --with-graphicsmagick to see if that correctly re-registers the include path.

motiooon commented 10 years ago

Thanks. Same error after uninstall and reinstall. Let me know when you get the chance to grab a mac. thanks for your help

pierreinglebert commented 10 years ago

What do you get with echo | cpp -Wp,-v ?

lovell commented 10 years ago

@motiooon Perhaps try brew unlink vips && brew link vips to force the recreation of vips' symlinks in /usr/local/include. Failing that, what does ls -al /usr/local/include display?

toulouse commented 10 years ago

Same exact issue here.

% ls -al /usr/local/include/vips
lrwxr-xr-x  1 toulouse  admin  34 May 27 16:40 /usr/local/include/vips -> ../Cellar/vips/7.38.5/include/vips

which I can confirm vips.h exists within.

unlink+linking doesn't work.

Hmm - but interestingly:

% echo | cpp -Wp,-v
clang -cc1 version 5.1 based upon LLVM 3.4svn default target x86_64-apple-darwin13.2.0
ignoring nonexistent directory "/usr/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks (framework directory)
End of search list.
# 1 "<stdin>"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 169 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "<stdin>" 2
motiooon commented 10 years ago

$ ls -al /usr/local/include total 320 drwxrwxr-x 43 root admin 1462 May 27 20:23 . drwxrwxr-x 21 root admin 714 May 26 16:09 .. lrwxr-xr-x 1 gabrielbaciu admin 56 May 26 12:58 GraphicsMagick -> ../Cellar/graphicsmagick/1.3.19_1/include/GraphicsMagick lrwxr-xr-x 1 gabrielbaciu admin 51 May 26 15:48 ImageMagick-6 -> ../Cellar/imagemagick/6.8.9-1/include/ImageMagick-6 lrwxr-xr-x 1 gabrielbaciu admin 48 May 26 14:12 autosprintf.h -> ../Cellar/gettext/0.18.3.2/include/autosprintf.h lrwxr-xr-x 1 gabrielbaciu admin 39 May 26 12:59 cairo -> ../Cellar/cairo/1.12.16_1/include/cairo lrwxr-xr-x 1 gabrielbaciu admin 36 May 26 12:59 fftw3.f -> ../Cellar/fftw/3.3.4/include/fftw3.f lrwxr-xr-x 1 gabrielbaciu admin 38 May 26 12:59 fftw3.f03 -> ../Cellar/fftw/3.3.4/include/fftw3.f03 lrwxr-xr-x 1 gabrielbaciu admin 36 May 26 12:59 fftw3.h -> ../Cellar/fftw/3.3.4/include/fftw3.h lrwxr-xr-x 1 gabrielbaciu admin 39 May 26 12:59 fftw3l.f03 -> ../Cellar/fftw/3.3.4/include/fftw3l.f03 lrwxr-xr-x 1 gabrielbaciu admin 39 May 26 12:59 fftw3q.f03 -> ../Cellar/fftw/3.3.4/include/fftw3q.f03 lrwxr-xr-x 1 gabrielbaciu admin 46 May 26 12:55 fontconfig -> ../Cellar/fontconfig/2.11.1/include/fontconfig lrwxr-xr-x 1 gabrielbaciu admin 44 May 26 12:55 freetype2 -> ../Cellar/freetype/2.5.3_1/include/freetype2 lrwxr-xr-x 1 gabrielbaciu admin 47 May 26 14:12 gettext-po.h -> ../Cellar/gettext/0.18.3.2/include/gettext-po.h lrwxr-xr-x 1 gabrielbaciu admin 44 May 26 12:57 gio-unix-2.0 -> ../Cellar/glib/2.40.0_1/include/gio-unix-2.0 lrwxr-xr-x 1 gabrielbaciu admin 40 May 26 12:57 glib-2.0 -> ../Cellar/glib/2.40.0_1/include/glib-2.0 lrwxr-xr-x 1 gabrielbaciu admin 72 May 26 12:59 gobject-introspection-1.0 -> ../Cellar/gobject-introspection/1.40.0/include/gobject-introspection-1.0 lrwxr-xr-x 1 gabrielbaciu admin 42 May 26 12:59 harfbuzz -> ../Cellar/harfbuzz/0.9.28/include/harfbuzz lrwxr-xr-x 1 gabrielbaciu admin 41 May 26 12:59 icc34.h -> ../Cellar/little-cms/1.19/include/icc34.h lrwxr-xr-x 1 gabrielbaciu admin 35 May 26 12:57 jconfig.h -> ../Cellar/jpeg/8d/include/jconfig.h lrwxr-xr-x 1 gabrielbaciu admin 34 May 26 12:57 jerror.h -> ../Cellar/jpeg/8d/include/jerror.h lrwxr-xr-x 1 gabrielbaciu admin 36 May 26 12:57 jmorecfg.h -> ../Cellar/jpeg/8d/include/jmorecfg.h lrwxr-xr-x 1 gabrielbaciu admin 35 May 26 12:57 jpeglib.h -> ../Cellar/jpeg/8d/include/jpeglib.h lrwxr-xr-x 1 gabrielbaciu admin 40 May 26 12:59 lcms.h -> ../Cellar/little-cms/1.19/include/lcms.h lrwxr-xr-x 1 gabrielbaciu admin 40 May 26 13:00 libexif -> ../Cellar/libexif/0.6.21/include/libexif lrwxr-xr-x 1 gabrielbaciu admin 44 May 26 14:12 libintl.h -> ../Cellar/gettext/0.18.3.2/include/libintl.h lrwxr-xr-x 1 gabrielbaciu admin 39 May 26 12:58 libltdl -> ../Cellar/libtool/2.4.2/include/libltdl lrwxr-xr-x 1 gabrielbaciu admin 40 May 26 12:55 libpng16 -> ../Cellar/libpng/1.6.10/include/libpng16 lrwxr-xr-x 1 gabrielbaciu admin 38 May 26 12:58 ltdl.h -> ../Cellar/libtool/2.4.2/include/ltdl.h drwxrwxr-x 23 root wheel 782 May 1 20:59 node lrwxr-xr-x 1 gabrielbaciu admin 36 May 26 12:58 orc-0.4 -> ../Cellar/orc/0.4.19/include/orc-0.4 lrwxr-xr-x 1 gabrielbaciu admin 40 May 26 13:00 pango-1.0 -> ../Cellar/pango/1.36.3/include/pango-1.0 lrwxr-xr-x 1 gabrielbaciu admin 40 May 26 12:59 pixman-1 -> ../Cellar/pixman/0.32.4/include/pixman-1 lrwxr-xr-x 1 gabrielbaciu admin 37 May 26 12:55 png.h -> ../Cellar/libpng/1.6.10/include/png.h lrwxr-xr-x 1 gabrielbaciu admin 41 May 26 12:55 pngconf.h -> ../Cellar/libpng/1.6.10/include/pngconf.h lrwxr-xr-x 1 gabrielbaciu admin 44 May 26 12:55 pnglibconf.h -> ../Cellar/libpng/1.6.10/include/pnglibconf.h lrwxr-xr-x 1 gabrielbaciu admin 38 May 26 12:58 tiff.h -> ../Cellar/libtiff/4.0.3/include/tiff.h lrwxr-xr-x 1 gabrielbaciu admin 42 May 26 12:58 tiffconf.h -> ../Cellar/libtiff/4.0.3/include/tiffconf.h lrwxr-xr-x 1 gabrielbaciu admin 40 May 26 12:58 tiffio.h -> ../Cellar/libtiff/4.0.3/include/tiffio.h lrwxr-xr-x 1 gabrielbaciu admin 42 May 26 12:58 tiffio.hxx -> ../Cellar/libtiff/4.0.3/include/tiffio.hxx lrwxr-xr-x 1 gabrielbaciu admin 42 May 26 12:58 tiffvers.h -> ../Cellar/libtiff/4.0.3/include/tiffvers.h lrwxr-xr-x 1 gabrielbaciu admin 34 May 27 20:23 vips -> ../Cellar/vips/7.38.5/include/vips lrwxr-xr-x 1 gabrielbaciu admin 35 May 26 13:00 webp -> ../Cellar/webp/0.4.0_1/include/webp

pierreinglebert commented 10 years ago

@toulouse It clearly doesn't search in /usr/include and /usr/local/include so it can't find vips. I don't know what I did to mine to make it search in those dirs.

Can you try CPLUS_INCLUDE_PATH=/usr/local/include npm install ?

Here is mine

clang -cc1 version 5.1 based upon LLVM 3.4svn default target x86_64-apple-darwin13.2.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
pierreinglebert commented 10 years ago

It seems from that issue https://github.com/Homebrew/homebrew-versions/issues/242 that you need to run xcode-select --install

toulouse commented 10 years ago

That fixes it.

lovell commented 10 years ago

Hi @motiooon, does @pierreinglebert's suggestion fix this problem for you also?

motiooon commented 10 years ago

I'll try it in about 3 hours and I'll let you know.

pierreinglebert commented 10 years ago

so @motiooon ?

motiooon commented 10 years ago

xcode-select --install did it for me also, thanks for helping out

homerjam commented 9 years ago

FWIW

I had xcode tools installed already and this did the job for me:

$ brew unlink vips && brew link vips

I got a warning so did this afterward as directed:

$ brew link --overwrite vips