I'm using alpine linux within my containers. A while back I had the same error as Package cairo was not found in the pkg-config search path. Node j.s install canvas issue I added the following snippet to my Dockerfile:
# Install cairo for one of our frontend dependencies
RUN apk add --update --no-cache cairo \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
This made the error go away (at least according to my memory, it's been a few months).
Today this error popped up again when running docker-compose exec web yarn watch
. Here's the full output of the error:
[4/4] Building fresh packages...
success Installed "node-gyp@3.8.0" with binaries:
[1/2] ⠠ canvas
warning Error running install script for optional dependency: "/var/www/html/node_modules/canvas: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /var/www/html/node_modules/canvas
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@8.14.0 | linux | x64
gyp http GET https://nodejs.org/download/release/v8.14.0/node-v8.14.0-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v8.14.0/node-v8.14.0-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v8.14.0/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v8.14.0/SHASUMS256.txt
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/local/share/.config/yarn/global/node_modules/node-gyp/gyp/gyp_main.py',
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 '/var/www/html/node_modules/canvas/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/share/.config/yarn/global/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/root/.node-gyp/8.14.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/root/.node-gyp/8.14.0',
gyp info spawn args '-Dnode_gyp_dir=/usr/local/share/.config/yarn/global/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/root/.node-gyp/8.14.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/var/www/html/node_modules/canvas',
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=.' ]
Package cairo was not found in the pkg-config search path.
Perhaps you should add the directory containing `cairo.pc'
to the PKG_CONFIG_PATH environment variable
Package 'cairo', required by 'virtual:world', not found
gyp: Call to './util/has_lib.sh freetype' returned exit status 0 while in binding.gyp. 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 (/usr/local/share/.config/yarn/global/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.9.125-linuxkit
gyp ERR! command \"/usr/bin/node\" \"/usr/local/bin/node-gyp\" \"rebuild\"
gyp ERR! cwd /var/www/html/node_modules/canvas
gyp ERR! node -v v8.14.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok"
Done in 98.27s.
I can prove Cairo is on the container:
WARNING: Ignoring APKINDEX.adfa7ceb.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.efaa1f73.tar.gz: No such file or directory
cairo-1.14.12-r2 description:
A vector graphics library
cairo-1.14.12-r2 webpage:
http://cairographics.org/
cairo-1.14.12-r2 installed size:
1097728
cairo-1.14.12-r2 depends on:
so:libX11.so.6
so:libXext.so.6
so:libXrender.so.1
so:libc.musl-x86_64.so.1
so:libfontconfig.so.1
so:libfreetype.so.6
so:libpixman-1.so.0
so:libpng16.so.16
so:libxcb-render.so.0
so:libxcb-shm.so.0
so:libxcb.so.1
so:libz.so.1
cairo-1.14.12-r2 provides:
so:libcairo-script-interpreter.so.2=2.11400.12
so:libcairo.so.2=2.11400.12
cairo-1.14.12-r2 is required by:
cairo-1.14.12-r2 contains:
usr/lib/libcairo.so.2.11400.12
usr/lib/libcairo-script-interpreter.so.2
usr/lib/libcairo-script-interpreter.so.2.11400.12
usr/lib/libcairo.so.2
usr/lib/cairo/cairo-sphinx.so.0
usr/lib/cairo/cairo-fdr.so.0
usr/lib/cairo/cairo-fdr.so
usr/lib/cairo/cairo-fdr.so.0.0.0
usr/lib/cairo/cairo-sphinx.so
usr/lib/cairo/cairo-sphinx.so.0.0.0
cairo-1.14.12-r2 triggers:
cairo-1.14.12-r2 has auto-install rule:
cairo-1.14.12-r2 affects auto-installation of:
cairo-1.14.12-r2 replaces:
cairo-1.14.12-r2 license:
LGPL-2.0-or-later MPL-1.1
I don't see any cairo.pc
file anywhere after some browsing, so how can I determine what step I need to take to educate my yarn install
on the location of cairo?