Adding Dependency to stack Project?

Viewed 5926

After running:

stack new my-project
cd my-project
stack setup
stack build

I would like to add the Conduit library as a dependency.

I edited the generated, via stack new, stack.yaml to have:

extra-deps: 
- conduit-1.2.10

Then, I modified the my-project.cabal from:

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

to:

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

When I try to stack build the following:

$cat app/Main.hs

module Main where

import Conduit
import Lib

main :: IO ()
main = someFunc

It fails:

$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

How can I properly add conduit?

When adding a library to a stack project, do I need to edit both the stack.yaml and/or my-project.cabal?

1 Answers
Related