HASKELL:APP构建故障排除(Docker Primer)



如果导入的库不构建,我应该如何进行故障排除?

$ stack new any-tool simple
$ cd any-tool/
$ stack build

样板构建。

import Turtle添加到Main.hs

{-# LANGUAGE OverloadedStrings #-}
module Main where
import Turtle
main :: IO ()
main = do
  putStrLn "hello world"

turtle添加到any-tool.cabal

....
executable any-tool
  hs-source-dirs:      src
  main-is:             Main.hs
  default-language:    Haskell2010
  build-depends:       base >= 4.7 && < 5
                     , turtle

不会构建:

$ stack build
clock-0.7.2: configure
clock-0.7.2: build
hashable-1.2.6.1: download
hashable-1.2.6.1: configure
hashable-1.2.6.1: build
hashable-1.2.6.1: copy/register
Progress: 2/30
--  While building custom Setup.hs for package clock-0.7.2 using:
      /home/alexey/.stack/setup-exe-cache/x86_64-linux-tinfo6-nopie/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0 build --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to: /home/alexey/spaces/haskell/any-tool/.stack-work/logs/clock-0.7.2.log
...

看起来并不特别:乌龟有几十个依赖性,任何不相容性,她去了。问题是,我的下一步是什么?

你最好排干沼泽。

https://www.fpcomplete.com/blog/2015/08/stack-docker

https://docs.haskellstack.org/en/stable/docker_integration

https://hub.docker.com/r/fpco/stack-build

我只花了次数安装docker

$  docker pull fpco/stack-build
...
$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED SIZE
...
fpco/stack-build    latest              4e3c147fca48        4 months ago        4.3GB
...

并在我的项目的stack.yaml中添加三行:

docker:
  enable: true
  image: 4e3c147fca48

图像不是很轻巧,但值得。

您可能可以将图像名称直接放入stack.yaml中:

docker:
  enable: true
  repo: "fpco/stack-build"

最新更新