1
运行后:添加依赖项来堆栈项目?
stack new my-project
cd my-project
stack setup
stack build
我想给Conduit库添加作为一个依赖。
我编辑所产生的,通过stack new
,stack.yaml
有:
extra-deps:
- conduit-1.2.10
然后,我修改了my-project.cabal
从:
executable my-project-exe
hs-source-dirs: app
main-is: Main.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends: base
, my-project
default-language: Haskell2010
到:
executable my-project-exe
hs-source-dirs: app
main-is: Main.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends: base
, my-project
, conduit
default-language: Haskell2010
当尝试到stack build
以下:
$cat app/Main.hs
module Main where
import Conduit
import Lib
main :: IO()
main = someFunc
它失败:
$stack build
mtl-2.2.1: using precompiled package
primitive-0.6.1.0: using precompiled package
stm-2.4.4.1: using precompiled package
transformers-compat-0.5.1.4: using precompiled package
exceptions-0.8.3: using precompiled package
mmorph-1.0.9: using precompiled package
transformers-base-0.4.4: using precompiled package
monad-control-1.0.1.0: using precompiled package
lifted-base-0.2.3.10: using precompiled package
resourcet-1.1.9: using precompiled package
conduit-1.2.10: configure
conduit-1.2.10: build
conduit-1.2.10: copy/register
my-project-0.1.0.0: configure (lib + exe)
Configuring my-project-0.1.0.0...
my-project-0.1.0.0: build (lib + exe)
Preprocessing library my-project-0.1.0.0...
[1 of 1] Compiling Lib (src/Lib.hs, .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/Lib.o)
Preprocessing executable 'my-project-exe' for my-project-0.1.0.0...
[1 of 1] Compiling Main (app/Main.hs, .stack-work/dist/x86_64-osx/Cabal-1.24.2.0/build/my-project-exe/my-project-exe-tmp/Main.o)
/Users/kevinmeredith/Workspace/conduit_sandbox/my-project/app/Main.hs:3:1: error:
Failed to load interface for ‘Conduit’
Use -v to see a list of the files searched for.
Completed 12 action(s).
-- While building package my-project-0.1.0.0 using:
/Users/kevinmeredith/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.24.2.0 build lib:my-project exe:my-project-exe --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
我怎样才能正确地添加conduit
?
将库添加到stack
项目时,是否需要编辑stack.yaml
和/或my-project.cabal
?
谢谢,@Erik。如果'conduit-libraries'不在堆栈中,那么我需要对我的'stack.yaml'做些什么? –
如果您想要编辑stack.yaml,例如,需要依赖本地软件包,可用于hackage而非堆栈的软件包,位于git repo中的软件包等。有关如何执行此操作的具体详细信息,请参阅https://docs.haskellstack.org/en/stable/GUIDE/#adding-dependencies – Erik
但是,您在原始问题中是否正确。要取消它,只需在extra-deps字段中列出软件包名称,堆栈应该为您下载它。 – Erik