Haskell / Stack / Nix构建失败,需要pkg-config> = 0.9.0和cairo> = 1.2.0,但最新版本是pkg-config 0.29.2和cairo 1.15.4

时间:2017-06-01 17:49:00

标签: haskell cairo haskell-stack nix nixpkgs

我正在使用Stack和Nix构建一个Haskell项目,具体取决于Hackage中的cairo库。

当我构建项目时,出现错误:无法找到pkg-config >= 0.9.0cairo >= 1.2.0。但是,根据其网站的最新版本为pkg-config 0.29.2cairo-1.15.4,这也反映在Nix包管理器中。

另一方面,还有 this article from 2006 announcing the release of Cairo 1.2.0,这进一步混淆了这个问题。

问题

  
      
  1. 为什么预期版本与nixpkgspkg-config / cairo网站上发布的版本截然不同?

  2.   
  3. 你有什么建议让cairo在macOS上构建(最好的情况:使用Nix作为系统包,使用Stack for Haskell包)

  4.   

重现的步骤:

> 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.

2 个答案:

答案 0 :(得分:6)

问题不在于库版本,1.14.8大于1.2.0。问题是,cairo开发文件没有链接到您的环境,即$PKG_CONFIG_PATH未设置。

三种解决方案:

  1. /nix/store中找到cairo-dev目录,并将其添加到PKG_CONFIG_PATH。如,

     $ cairodev=$(nix-store --query --outputs $(nix-instantiate '<nixpkgs>' -A cairo) | grep dev$)
     $ export PKG_CONFIG_PATH=$cairodev:$PKG_CONFIG_PATH
    
  2. 在nix shell nix-shell -p pkgconfig cairo内运行堆栈。

  3. 使用stack&#nix支持,将以下内容添加到stack.yml

    nix:
      enable: true
      packages: [pkgconfig, cairo]
    

答案 1 :(得分:0)

通过安装Homebrew,然后使用 -webkit-transition: all 1s; // Chrome -moz-transition: all 1s; // Mozilla -o-transition: all 1s; // Opera transition: all 1s; 安装cairo,我就能够构建项目。

然而,这个安装了开机版1.14 - 和Nix安装的一样!当我用brew install cairo进行检查时,我会看到更多信息:

brew info cairo

我尝试使用Nix安装这些依赖项,并卸载Homebrew。没有运气 - 有大量的链接错误。所以我重新安装了Homebrew,它再次运行。

这不是我正在寻找的漂亮,干净的解决方案(必须安装外部软件包管理器),但它现在确实解决了这个问题。