Skip to content

Dependency issues with cabal repl and test-suites #2032

Closed
@sol

Description

@sol

cabal repl still does not work properly for test suites. If the test suite depends on the library component (which is pretty common!), we run into dependency issues.

Steps to reproduce

Create the following files:

$ tree
.
├── foo.cabal
├── src
│   └── Foo.hs
└── test
    └── Spec.hs

2 directories, 3 files
-- foo.cabal
name:           foo
version:        0.0.0
build-type:     Simple
cabal-version:  >= 1.8

library
  hs-source-dirs: src
  exposed-modules: Foo
  build-depends: base, process

test-suite spec
  type: exitcode-stdio-1.0
  hs-source-dirs: test
  main-is: Spec.hs
  build-depends: base, foo, hspec
-- src/Foo.hs
module Foo where

import System.Process

foo :: Int
foo = 42
-- test/Spec.hs
module Main (main) where
import           Test.Hspec
import           Foo

main :: IO ()
main = hspec $ do
  describe "foo" $ do
    it "it is 42" $ do
      foo `shouldBe` 42

Running the specs with cabal test works, but running cabal repl spec fails:

$ cabal repl spec
src/Foo.hs:3:8:
    Could not find module ‘System.Process’
    It is a member of the hidden package ‘process-1.2.0.0’.
    Perhaps you need to add ‘process’ to the build-depends in your .cabal file.
    Use -v to see a list of the files searched for.
Failed, modules loaded: none.
Prelude> 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions