Stack / Cabal找不到开心

时间:2016-08-18 06:17:18

标签: haskell cabal haskell-stack

我尝试使用Haskell Stack构建the code from PCPH。但是,我收到有关Cabal未找到happy的错误。我已经安装了alexhappy(他们在/usr/bin中)。

setup-Simple-Cabal-1.22.5.0-ghc-7.10.3: The program 'happy' is required but it
could not be found

--  While building package parconc-examples-0.4.3 using:

这里的堆栈认为我的PATH是:

$ stack exec bash
$ echo $PATH | tr : '\n'
/home/steshaw/Projects/parconc-examples/.stack-work/install/x86_64-linux/lts-4.2/7.10.3/bin
/home/steshaw/Projects/shelly/dotfiles/.stack/snapshots/x86_64-linux/lts-4.2/7.10.3/bin
/home/steshaw/Projects/shelly/dotfiles/.stack/programs/x86_64-linux/ghc-7.10.3/bin
/home/steshaw/.nix-profile/bin
/home/steshaw/.nix-profile/sbin
/usr/local/sbin
/usr/local/bin
/home/steshaw/Projects/shelly/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin

这是stack path的输出:

stack-root: /home/steshaw/Projects/shelly/dotfiles/.stack
project-root: /home/steshaw/Projects/parconc-examples
config-location: /home/steshaw/Projects/parconc-examples/stack.yaml
bin-path: /home/steshaw/Projects/shelly/dotfiles/.stack/snapshots/x86_64-linux/lts-4.2/7.10.3/bin:/home/steshaw/Projects/shelly/dotfiles/.stack/programs/x86_64-linux/ghc-7.10.3/bin:/home/steshaw/.nix-profile/bin:/home/steshaw/.nix-profile/sbin:/usr/local/sbin:/usr/local/bin:/home/steshaw/Projects/shelly/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
programs: /home/steshaw/Projects/shelly/dotfiles/.stack/programs/x86_64-linux
compiler-exe: /home/steshaw/Projects/shelly/dotfiles/.stack/programs/x86_64-linux/ghc-7.10.3/bin/ghc
compiler-bin: /home/steshaw/Projects/shelly/dotfiles/.stack/programs/x86_64-linux/ghc-7.10.3/bin
local-bin: /home/steshaw/.local/bin
extra-include-dirs: 
extra-library-dirs: 
snapshot-pkg-db: /home/steshaw/Projects/shelly/dotfiles/.stack/snapshots/x86_64-linux/lts-4.2/7.10.3/pkgdb
local-pkg-db: /home/steshaw/Projects/parconc-examples/.stack-work/install/x86_64-linux/lts-4.2/7.10.3/pkgdb
global-pkg-db: /home/steshaw/Projects/shelly/dotfiles/.stack/programs/x86_64-linux/ghc-7.10.3/lib/ghc-7.10.3/package.conf.d
ghc-package-path: /home/steshaw/Projects/parconc-examples/.stack-work/install/x86_64-linux/lts-4.2/7.10.3/pkgdb:/home/steshaw/Projects/shelly/dotfiles/.stack/snapshots/x86_64-linux/lts-4.2/7.10.3/pkgdb:/home/steshaw/Projects/shelly/dotfiles/.stack/programs/x86_64-linux/ghc-7.10.3/lib/ghc-7.10.3/package.conf.d
snapshot-install-root: /home/steshaw/Projects/shelly/dotfiles/.stack/snapshots/x86_64-linux/lts-4.2/7.10.3
local-install-root: /home/steshaw/Projects/parconc-examples/.stack-work/install/x86_64-linux/lts-4.2/7.10.3
snapshot-doc-root: /home/steshaw/Projects/shelly/dotfiles/.stack/snapshots/x86_64-linux/lts-4.2/7.10.3/doc
local-doc-root: /home/steshaw/Projects/parconc-examples/.stack-work/install/x86_64-linux/lts-4.2/7.10.3/doc
dist-dir: .stack-work/dist/x86_64-linux/Cabal-1.22.5.0
local-hpc-root: /home/steshaw/Projects/parconc-examples/.stack-work/install/x86_64-linux/lts-4.2/7.10.3/hpc
local-bin-path: /home/steshaw/.local/bin
ghc-paths: /home/steshaw/Projects/shelly/dotfiles/.stack/programs/x86_64-linux

这是我在路径上找到的快乐版本:

$ stack exec -- happy -V
Happy Version 1.19.5 Copyright (c) 1993-1996 Andy Gill, Simon Marlow (c) 1997-2005 Simon Marlow

Happy is a Yacc for Haskell, and comes with ABSOLUTELY NO WARRANTY.
This program is free software; you can redistribute it and/or modify
it under the terms given in the file 'LICENSE' distributed with
the Happy sources.

我在Ubuntu 16.04.1 LTS(x86_64)上。

1 个答案:

答案 0 :(得分:2)

要尝试两件事:

  1. 使用项目解析器安装happy via stack:

    stack install happy --resolver lts-4.2
    
  2. 当我用解析器lts-4.2构建parconc-examples时,我发现了它 即使在lts-4.2快照目录中使用了快乐二进制文件 我把它安装在PATH的其他地方。

    1. 使用此Setup.hs程序:

      import Distribution.Simple
      import System.Environment
      
      main = do
        args <- getArgs
        let args' = if elem "configure" args
                      then args ++ [ "--with-happy=/usr/bin/happy" ]
                      else args
        defaultMainWithArgs args'
      
    2. 并且还要确保将parconc-examples.cabal中的build-type:更改为Custom。完全删除.stack-work目录以确保使用新的安装程序重建所有内容。