Search code examples
haskellcabal

Error while creating test suites: "cannot satisfy -package-id"


I'm attempting to create a test suite for my project, HaskSplit in my .cabal configuration:

-- Initial HaskSplit.cabal generated by cabal init.  For further 
-- documentation, see http://haskell.org/cabal/users-guide/

name:                HaskSplit
version:             0.1.0.0
synopsis:            Haskell Implementation of Shamir's Secret Sharing Scheme
-- description:         
license:             MIT
license-file:        LICENSE
author:              
maintainer:          
-- copyright:           
category:            Security
build-type:          Simple
-- extra-source-files:  
cabal-version:       >=1.10

executable HaskSplit
  main-is:             Main.hs
  default-language:    Haskell2010
  -- other-modules:       
  other-extensions:    TemplateHaskell, NoImplicitPrelude, RankNTypes, OverloadedStrings
  build-depends:       base >=4.6 && <4.7,
                       resourcet >=1.1 && <1.2,
                       bytestring >=0.10 && <0.11,
                       conduit-extra >=1.1 && <1.2,
                       vector >=0.10 && <0.11,
                       conduit >=1.1 && <1.2,
                       conduit-combinators >=0.2 && <0.3,
                       mono-traversable >=0.5 && <0.6,
                       safe >=0.3 && <0.4,
                       transformers >=0.3 && <0.4,
                       filepath >= 1.3,
                       directory >=1.2,
                       Glob >= 0.7.4,
                       errors >= 1.4,
                       optparse-applicative >= 0.8
  hs-source-dirs:      src
  default-language:    Haskell2010
  ghc-options:         -Wall -fno-warn-orphans

test-suite tests
  type:                exitcode-stdio-1.0
  default-language:    Haskell2010
  hs-source-dirs:      tests
  main-is:             Test.hs
  ghc-options:         -Wall -fno-warn-orphans
  build-depends:       base == 4.*,
                       QuickCheck >=2.6 && <2.7,
                       test-framework-quickcheck2 >= 0.3.0.3,
                       HaskSplit

Looking at an example test-suite setup here, I noticed that they're specifying their own package as one of the build-depends module. Therefore I did the same, so that I can keep my build-depends list for my test-suite short.

However when I try cabal repl test:tests in commandline, I'm getting the following error:

<command line>: cannot satisfy -package-id HaskSplit-0.1.0.0-inplace

I'm not too sure what I'm missing here, can anyone help me out? Is it cyclic dependencies happening around here? Or do I need to create a library instance of my package for the build-depends to work?

Thanks!


Solution

  • The build-depends section can only contain libraries, not modules. I suggest you add a library to your cabal file. The exposed-modules section of the library should list all of the modules that your test (or any other user of the library) might need to reference.

    As an alternative to creating a library, you could simply add the modules you need to the other-modules part of the test-suite section. If you want to include a lot of modules, though, I think the library approach is nicer.