Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fatal error: 'cairo.h' file not found #16670

Closed
DoneDeal0 opened this issue Jul 8, 2023 · 1 comment
Closed

fatal error: 'cairo.h' file not found #16670

DoneDeal0 opened this issue Jul 8, 2023 · 1 comment

Comments

@DoneDeal0
Copy link

DoneDeal0 commented Jul 8, 2023

Hello,

I have an Electron app that uses pdfjs-dist. On Mac OSX, the app was working perfectly. But I had to use a new computer with OSX Ventura 13.4.1 (the latest Apple os).

When simply installing pdfjs-dist, not even importing nor using it, the app can't compile and crashes immediately. The error is:

 Package 'gobject-2.0' requires 'libffi >= 3.0.0' but version of libffi is 2.1
  Package 'gobject-2.0' requires 'libffi >= 3.0.0' but version of libffi is 2.1
  SOLINK_MODULE(target) Release/canvas-postbuild.node
  CXX(target) Release/obj.target/canvas/src/backend/Backend.o
  In file included from ../src/backend/Backend.cc:1:
  ../src/backend/Backend.h:3:10: fatal error: 'cairo.h' file not found
  #include <cairo.h>
  ^~~~~~~~~
  1 error generated.
  make: *** [Release/obj.target/canvas/src/backend/Backend.o] Error 1
  Error: `make` failed with exit code: 2
  at ChildProcess.onExit (/Users/myname/Desktop/myapp/node_modules/node-gyp/lib/build.j…
  at ChildProcess.emit (node:events:513:28)
  at ChildProcess._handle.onexit (node:internal/child_process:291:12)

An unhandled rejection has occurred inside Forge:
Error: node-gyp failed to rebuild '/Users/myname/Desktop/myapp/node_modules/canvas'
at ChildProcess.<anonymous> (/Users/myname/Desktop/myapp/node_modules/@electron/rebuild/lib/module-type/node-gyp/node-gyp.js:118:24)
    at ChildProcess.emit (node:events:513:28)
    at ChildProcess._handle.onexit (node:internal/child_process:291:12)

I have browsed your github issues, and I have installed every related packages that might be needed with brew: pkg-config, cairo , pango, libpng, jpeg, giflib, librsvg, libffi. The computer has Node 18.16.1.

Configuration:

  • Operating system and its version: OSX 13.4.1 (Ventura)
  • PDF.js version: 3.8.162

I know the issue talks about Electron, BUT, the crash happens when simply installing pdfjs-dist, so the issue definitely comes from here. Also, canvas is marked as an optionalDependenciesof pdfjs-dist. Maybe I need to install an additional package?

Thank you!

@timvandermeij
Copy link
Contributor

timvandermeij commented Jul 8, 2023

The problem is that the canvas dependency is being built from source instead of using the prebuilt version, which does appear to be available at https://github.com/Automattic/node-canvas/releases (it should be
canvas-v2.11.2-node-v108-darwin-unknown-x64.tar.gz given that Node 18.16.1 corresponds to ABI version 108 according to https://nodejs.org/en/download/releases). If you have M1, maybe it has something to do with Automattic/node-canvas#2253 and Automattic/node-canvas#2036 not being implemented yet upstream.

In any case, what I think you're missing is libcairo2-dev (see https://packages.debian.org/sid/libcairo2-dev, not sure what the OSX alternative is given that I only use Linux) since that contains the development header files; usually those are separate from the regular cairo package.

Hopefully this helps, but otherwise the question is better asked upsteam in the canvas bug tracker at https://github.com/Automattic/node-canvas since we don't know more about it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants