如果导入的库无法构建,我该如何进行故障排除?
$ 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
...
看起来并不特别惊讶:turtle有几十个依赖项,任何不兼容性,她就去了。问题是,我的下一步是什么?
答案 0 :(得分:0)
你最好把沼泽排干。
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"