Reputation: 1
I am working on my first major Haskell application, and want to add mockery to create disposable test WAI threads. Importing mockery and running stack test
resulted in the compiler error:
Failed to load interface for ‘Test.Mockery.Directory’
It is a member of the hidden package ‘mockery-0.3.5’.
Perhaps you need to add ‘mockery’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
So, I added mockery to my cabal file under test dependencies. However, when I run stack build
or stack test
mockery is automatically removed from the cabal file.
I have also tried listing mockery-0.3.5
under extra-deps
in the stack.yaml
file. This unsurprisingly didn't work, since mockery is part of my lts, and extra deps is for packages outside of lts.
How can I get stack to recognize that mockery should be included as a dependency to to project?
Here is my stack.yaml:
flags: {}
ghc-options:
! '*': -Wall
packages:
- .
extra-deps: [
]
resolver: lts-9.5
I'm using stack version 1.5.1
I imagine this is a stupid build issue and look forward to confronting my obvious oversight.
Upvotes: 0
Views: 320
Reputation: 2214
In stack.yaml
you declare the Stackage LTS version, a curated list of hackage dependencies that you want to depend on. You can also depend on local packages and packages in git that are not in Hackage. You may also change the versions of the packages in LTS as long as they respect the constraints of the other dependencies.
package.yaml
is the build file. Any packages you want to import directly in your Haskell code must be declared in here as dependencies, even if they are explicitly declared in the stack.yaml
.
Finally, when you see It is a member of the hidden package
, that means that one of your dependencies is using that package, but it is not declared as a dependency in your build file.
Upvotes: 0