mojodna / heroku-buildpack-cairo

Heroku buildpack with Cairo (and Pixman and FreeType)
34 stars 63 forks source link

heroku deploy error - gif_lib.h: No such file or directory #13

Closed bitbay closed 8 years ago

bitbay commented 8 years ago

Getting an error using the latest version of node-canvas (1.3.10) and master branch of heroku-buildpack-cairo, using the method commented in the README.md (pasting the conlicting lines only)

remote:        g++ '-DNODE_GYP_MODULE_NAME=canvas' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DHAVE_FREETYPE' '-DHAVE_JPEG' '-DHAVE_GIF' '-DBUILDING_NODE_EXTENSION' -I/app/.node-gyp/5.4.0/include/node -I/app/.node-gyp/5.4.0/src -I/app/.node-gyp/5.4.0/deps/uv/include -I/app/.node-gyp/5.4.0/deps/v8/include -I../../nan -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12  -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -ffunction-sections -fdata-sections -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++0x -MMD -MF ./Release/.deps/Release/obj.target/canvas/src/CanvasPattern.o.d.raw  -c -o Release/obj.target/canvas/src/CanvasPattern.o ../src/CanvasPattern.cc
remote:        In file included from ../src/CanvasPattern.cc:9:0:
remote:        ../src/Image.h:19:21: fatal error: gif_lib.h: No such file or directory
remote:        #include <gif_lib.h>
remote:        ^
remote:        compilation terminated.
remote:        make: *** [Release/obj.target/canvas/src/CanvasPattern.o] Error 1
remote:        make: Leaving directory `/tmp/build_70eeb9165bb4d01ecf2c04930e94c802/node_modules/canvas/build'

Is this a known issue? Are there workarounds or should i use a specific version of buildpack/canvas?

bitbay commented 8 years ago

Building from inside a heroku instance (last push with NODE_MODULES_CACHE=true) seems to work fine though...

$ heroku run bash
~ $ rm -rf node_modules
~ $ npm install
mojodna commented 8 years ago

No, not a known issue (although I'm not actively using node-canvas on Heroku).

The underlying problem appears to be that the compiler isn't finding gif_lib.h in any of the standard directories despite paths being set properly. (CPATH / CPPPATH: https://github.com/mojodna/heroku-buildpack-cairo/blob/master/bin/compile#L37-L38)

Are you using any other buildpacks? If so, what's the order in which they're defined?

When running from heroku bash, does it show compiler output when installing canvas?

bitbay commented 8 years ago

Are you using any other buildpacks? If so, what's the order in which they're defined?

Indeed, i use heroku-buildpack-multi with the following .buildpacks file:

https://github.com/mojodna/heroku-buildpack-cairo
https://github.com/heroku/heroku-buildpack-nodejs.git

I don´t think that the multiple buildpacks cause the issue.

When running from heroku bash, does it show compiler output when installing canvas?

Yes it does. No errors though, canvas builds fine.

mojodna commented 8 years ago

Agreed, multiple buildpacks doesn't seem to be the problem.

Looking back at:

remote:        g++ '-DNODE_GYP_MODULE_NAME=canvas' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DHAVE_FREETYPE' '-DHAVE_JPEG' '-DHAVE_GIF' '-DBUILDING_NODE_EXTENSION' -I/app/.node-gyp/5.4.0/include/node -I/app/.node-gyp/5.4.0/src -I/app/.node-gyp/5.4.0/deps/uv/include -I/app/.node-gyp/5.4.0/deps/v8/include -I../../nan -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12  -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -ffunction-sections -fdata-sections -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++0x -MMD -MF ./Release/.deps/Release/obj.target/canvas/src/CanvasPattern.o.d.raw  -c -o Release/obj.target/canvas/src/CanvasPattern.o ../src/CanvasPattern.cc

None of the /app/vendor/<lib>/include directories are listed as -I arguments. g++ should be picking them up from CPPPATH (when not listed), but something in node-canvas / node-gyp may have changed preventing that...

If you're willing to fork the nodejs buildpack w/ debugging information, it would be useful to echo $CPPPATH early on (or possibly in an additional buildpack slotted after the Cairo buildpack).

ENV_DIR (referenced in https://devcenter.heroku.com/articles/buildpack-api) may be the underlying problem. Specifically, not using it correctly. It's possible that most apps sneak around the fact that this isn't doing anything because enough of the dependencies are available in the cedar-14 slug.

bitbay commented 8 years ago

If you're willing to fork the nodejs buildpack w/ debugging information, it would be useful to echo $CPPPATH early on (or possibly in an additional buildpack slotted after the Cairo buildpack).

thank You for the hint, will give the slotted-buildpack approach a try and post the results!

bitbay commented 8 years ago

Quick follow-up on the topic. Did an empty nodejs project with only canvas as a dependency, using multi-buildpacks as recommended, with the only line of echo $CPPPATH in the bin/detect script, which gives this result

:/tmp/build_3f670ab6a2077b8901c1d178556385d1/vendor/cairo/include/cairo:/tmp/build_3f670ab6a2077b8901c1d178556385d1/vendor/pixman/include/pixman-1:/tmp/build_3f670ab6a2077b8901c1d178556385d1/vendor/freetype/include/freetype2:/tmp/build_3f670ab6a2077b8901c1d178556385d1/vendor/pango/include/pango-1.0:/tmp/build_3f670ab6a2077b8901c1d178556385d1/vendor/fontconfig/include:/tmp/build_3f670ab6a2077b8901c1d178556385d1/vendor/harfbuzz/include:/tmp/build_3f670ab6a2077b8901c1d178556385d1/vendor/pango/include:/tmp/build_3f670ab6a2077b8901c1d178556385d1/vendor/pixman/include:/tmp/build_3f670ab6a2077b8901c1d178556385d1/vendor/giflib/include:/tmp/build_3f670ab6a2077b8901c1d178556385d1/vendor/freetype/include:/tmp/build_3f670ab6a2077b8901c1d178556385d1/vendor/cairo/include:
...
remote: -----> Build succeeded!
remote:        └── canvas@1.3.10

The heroku push works as expected, canvas compiles. Will plug the debug buildpack of mine into my live project and see what it does differently...

bitbay commented 8 years ago

It seems that the error was specific to some node/npm versions. Using the latest ones from heroku the build works flawlessly.

-----> Installing binaries
       engines.node (package.json):  5.6.0
       engines.npm (package.json):   3.6.0

Closing, and thanks for the support and quick response @mojodna !

mojodna commented 8 years ago

Fantastic, glad it's working!

nicholaswmin commented 6 years ago

For people that still experience this issue, the following solved my problem:

Add this buildpack before the Node.js buildpack in Heroku's dashboard.