I'm building a Haskell project using Stack and Nix and depending on the cairo
library from Hackage.
When I build the project, I get an error: unable to find pkg-config >= 0.9.0
or cairo >= 1.2.0
. However, the latest versions according to their websites are pkg-config 0.29.2
and cairo-1.15.4
, and this is reflected in the Nix package manager as well.
On the other hand, there's this article from 2006 announcing the release of Cairo 1.2.0, which further confuses the issue.
Why are the expected versions so wildly different from the published versions on
nixpkgs
and thepkg-config
/cairo
websites?What advice do you have to get
cairo
to build on macOS (best case scenario: using Nix for system packages and Stack for Haskell packages)
Steps to reproduce:
> stack new cairo-test simple && cd cairo-test
# Now, to get Cairo
> stack install cairo
cairo-0.13.3.1: configure ...
Process exited with code: ExitFailure 1
Configuring cairo-0.13.3.1...
setup: The program 'pkg-config' version >=0.9.0 is required but it could not be found.
# This version doesn't seem to exist (not on the pkg-config website, either).
> nix-env -qaP pkg-config
nixpkgs.pkgconfig pkg-config-0.29.2
nixpkgs.pkgconfigUpstream pkg-config-0.29.2
# However, if installed, a new error:
> nix-env -i pkg-config
installing ‘pkg-config-0.29.2’
building path(s) ‘/nix/store/m4ks2si7b78757c1rc43r0833pxkvjb3-user-environment’
created 102 symlinks in user environment
> stack install cairo
setup: The pkg-config package 'cairo' version >=1.2.0 is required but
it could not be found.
# Again, this version doesn't seem to exist, either on the site on in `nixpkgs`
> nix-env -qaP cairo
nixpkgs.cairo cairo-1.14.8
# Installing it anyway, to see what the next error is
> nix-env -i cairo
installing ‘cairo-1.14.8’
building path(s) ‘/nix/store/dcx0in96wcd7yd8q71y93jd5306vag8g-user-environment’
created 112 symlinks in user environment
# Get the same version error now that Cairo is installed
setup: The pkg-config package 'cairo' version >=1.2.0 is required but it could not be found.
By installing Homebrew and then cairo with brew install cairo
, I was able to build the project.
However, this installed Cairo version 1.14 — the same that Nix installed! When I inspect with brew info cairo
, I see some more information:
cairo: stable 1.14.8 (bottled), devel 1.15.4, HEAD
==> Dependencies
Build: pkg-config ✘
Required: freetype ✔, fontconfig ✔, libpng ✔, pixman ✔, glib ✔
I tried installing these dependencies with Nix, and uninstalling Homebrew. No luck -- got a ton of linking errors. And so I re-installed Homebrew and it works again.
This isn't the nice, clean solution I was looking for (had to install an external package manager), but it does solve the problem for now.