Skip to content

for brewed OSX cairo, fix "Package 'xcb-shm', required by 'cairo', not found" error #541

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

Closed
wants to merge 1 commit into from

Conversation

heavyk
Copy link

@heavyk heavyk commented Mar 21, 2015

No description provided.

@henrahmagix
Copy link

This has worked for me, please consider merging

@joevennix
Copy link

I also needed to change this env var to make it work with my homebrew installation of cairo. +1 for merging this

@mathiasbynens
Copy link
Contributor

Same problem here. I can confirm that this patch fixes the problem.

export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/opt/X11/lib/pkgconfig" && npm install canvas --save

@heavyk
Copy link
Author

heavyk commented Jul 1, 2015

there have been new releases since I made this patch...
so, dunno why it didn't get merged yet. I think it affects everyone with homebrew.

@kangax
Copy link
Collaborator

kangax commented Jul 1, 2015

Ah yes, I think I needed to define that path as well when installing on Yosemite through brew. Would the build.sh script be called when doing 'npm install canvas'? Does npm invoke install script?

@mathiasbynens
Copy link
Contributor

From https://docs.npmjs.com/misc/scripts:

install, postinstall: Run after the package is installed.

@heavyk
Copy link
Author

heavyk commented Jul 1, 2015

so, the idea is it that PKG_CONFIG_PATH needs to be exported for node-gyp to see it. the only way to do that (that I know of) is with a script. I think I tried unsuccessfully to inline it.

EDIT: or was it pkg-config that needed it ??? I can't remember now... export needed to happen in the script though

@kangax
Copy link
Collaborator

kangax commented Jul 1, 2015

Hm, shouldn't it be preinstall then?

Sent from my iPad

On Jul 1, 2015, at 10:06 AM, kenny [email protected] wrote:

so, the idea is it that PKG_CONFIG_PATH needs to be exported for node-gyp to see it. the only way to do that (that I know of) is with a script. I think I tried unsuccessfully to inline it.


Reply to this email directly or view it on GitHub.

@heavyk
Copy link
Author

heavyk commented Jul 1, 2015

if you define an install script, it actually replaces the install command (which npm runs for you). this is why it runs node-gyp rebuild

although, now that I think about it, I have no idea what the behaviour on windows would be.

@mathiasbynens
Copy link
Contributor

@kangax I think you’re right — preinstall (“run BEFORE the package is installed”) seems ideal here.

"preinstall": "[[ \"$(uname)\" = \"Darwin\" ]] && export PKG_CONFIG_PATH=\"${PKG_CONFIG_PATH}:/opt/X11/lib/pkgconfig\""

@heavyk
Copy link
Author

heavyk commented Jul 6, 2015

@mathiasbynens - I think when I tried that, the export didn't make it into node-gyp ... I could be wrong though. did you try it?

@LinusU
Copy link
Collaborator

LinusU commented Jul 6, 2015

With #574 merged I do not need this to make it work. I don't even have a /opt/X11 directory.

This works without any errors:

PKG_CONFIG_PATH="" npm install LinusU/node-canvas#include-paths

@heavyk
Copy link
Author

heavyk commented Jul 6, 2015

@LinusU 👍 for yours 👏

@TooTallNate
Copy link
Contributor

@LinusU Your command doesn't seem to fix this particular issues still:

$ PKG_CONFIG_PATH="" npm install LinusU/node-canvas#include-paths
|
> [email protected] install /Users/nrajlich/node_modules/canvas
> node-gyp rebuild

Package xcb-shm was not found in the pkg-config search path.
Perhaps you should add the directory containing `xcb-shm.pc'
to the PKG_CONFIG_PATH environment variable
Package 'xcb-shm', required by 'cairo', not found
gyp: Call to './util/has_cairo_freetype.sh' returned exit status 0. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/nrajlich/.nvm/versions/node/v0.12.6/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:355:16)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Darwin 14.4.0
gyp ERR! command "node" "/Users/nrajlich/.nvm/versions/node/v0.12.6/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/nrajlich/node_modules/canvas
gyp ERR! node -v v0.12.6
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
npm ERR! Darwin 14.4.0
npm ERR! argv "/Users/nrajlich/.nvm/versions/node/v0.12.6/bin/node" "/Users/nrajlich/.nvm/versions/node/v0.12.6/bin/npm" "install" "LinusU/node-canvas#include-paths"
npm ERR! node v0.12.6
npm ERR! npm  v2.11.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the canvas 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 canvas
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/nrajlich/npm-debug.log

@TooTallNate
Copy link
Contributor

That said, I don't think this particular PR is correct either. Remember that a bash script won't run on Windows!

@LinusU
Copy link
Collaborator

LinusU commented Jul 6, 2015

@TooTallNate Hmm, that's strange. I'll have to dig deeper here. Do you have pango installed?

@heavyk
Copy link
Author

heavyk commented Jul 6, 2015

@TooTallNate yeah I realized that after I made the PR. will a normal npm preinstall script will work though? I'll be willing to update this PR

@LinusU it does work for me though ... hmmm

@heavyk
Copy link
Author

heavyk commented Jul 6, 2015

very strange: now, for me, npm i canvas works and so does @LinusU 's branch however, npm i Automattic/node-canvas produces this:

  SOLINK_MODULE(target) Debug/canvas-postbuild.node
  CXX(target) Debug/obj.target/canvas/src/Canvas.o
  CXX(target) Debug/obj.target/canvas/src/CanvasGradient.o
  CXX(target) Debug/obj.target/canvas/src/CanvasPattern.o
  CXX(target) Debug/obj.target/canvas/src/CanvasRenderingContext2d.o
  CXX(target) Debug/obj.target/canvas/src/color.o
  CXX(target) Debug/obj.target/canvas/src/Image.o
  CXX(target) Debug/obj.target/canvas/src/ImageData.o
  CXX(target) Debug/obj.target/canvas/src/init.o
  CXX(target) Debug/obj.target/canvas/src/PixelArray.o
../src/CanvasPattern.cc:81:3: error: member initializer '_width' does not name a non-static data member
      or base class
  _width(w), _height(h) {
  ^~~~~~~~~
../src/CanvasPattern.cc:81:14: error: member initializer '_height' does not name a non-static data
      member or base class
  _width(w), _height(h) {
             ^~~~~~~~~~
In file included from ../src/CanvasRenderingContext2d.cc:22:
../src/FontFace.h:22:8: error: initializer '_ftFace' does not name a non-static data member or base
      class; did you mean the member '_crFace'?
      :_ftFace(ftFace), _crFace(crFace) {}
       ^~~~~~~
       _crFace
../src/FontFace.h:27:24: note: '_crFace' declared here
    cairo_font_face_t *_crFace;
                       ^
2 errors generated.
make: *** [Debug/obj.target/canvas/src/CanvasPattern.o] Error 1
../src/FontFace.h:22:8: error: cannot initialize a member make: subobject*** Waiting for unfinished jobs....
of type 'cairo_font_face_t *'
      (aka '_cairo_font_face *') with an lvalue of type 'FT_Face' (aka 'FT_FaceRec_ *')
      :_ftFace(ftFace), _crFace(crFace) {}
       ^       ~~~~~~
../src/CanvasRenderingContext2d.cc:379:22: warning: unused variable 'surface' [-Wunused-variable]
    cairo_surface_t *surface = cairo_get_group_target(_context);
                     ^
1 warning and 2 errors generated.
make: *** [Debug/obj.target/canvas/src/CanvasRenderingContext2d.o] Error 1
In file included from ../src/init.cc:18:
../src/FontFace.h:22:8: error: initializer '_ftFace' does not name a non-static data member or base
      class; did you mean the member '_crFace'?
      :_ftFace(ftFace), _crFace(crFace) {}
       ^~~~~~~
       _crFace
../src/FontFace.h:27:24: note: '_crFace' declared here
    cairo_font_face_t *_crFace;
                       ^
../src/FontFace.h:22:8: error: cannot initialize a member subobject of type 'cairo_font_face_t *'
      (aka '_cairo_font_face *') with an lvalue of type 'FT_Face' (aka 'FT_FaceRec_ *')
      :_ftFace(ftFace), _crFace(crFace) {}
       ^       ~~~~~~
2 errors generated.
make: *** [Debug/obj.target/canvas/src/init.o] Error 1

@garthk garthk mentioned this pull request Jul 23, 2015
@LinusU
Copy link
Collaborator

LinusU commented Jul 29, 2015

Could anyone please test this with the latest version, and if it doesn't work:

  • Make sure that all brew packages are updated
  • Post a list of what files lies in /opt/X11/lib/pkgconfig
  • Post if pango is installed or not

Thanks!

@LinusU
Copy link
Collaborator

LinusU commented Oct 29, 2016

No response in over a year so I'll go ahead and close this. If anyone still has this issue I would be happy to help debugging...

@LinusU LinusU closed this Oct 29, 2016
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

Successfully merging this pull request may close these issues.

7 participants