jules
jules

Reputation: 1917

cabal doesn't find Source.hs

My project structure is as follows:

~/.../project_name
project_name.cabal
Setup.hs
src/
    Main.hs
    Data/
        ...
test/
    MainTestSuite
    ...

I have (amongst others) the following lines in my project.cabal:

build-type:          Simple
...
executable project_name
main-is: Main.hs
...
hs-source-dirs: src

When I cabal configure (works fine) and then cabal build I get the error message:

cabal: can't find source for Setup in src, dist/build/autogen

It works when I put Source.hs in src but this seems messy to me and I haven't seen this in other projects, where Source.hs is always in the project root. How do I get cabal to find Source.hs?


As an aside: What's the purpose of Source.hs anyways?

Upvotes: 8

Views: 4032

Answers (2)

jules
jules

Reputation: 1917

The problem was caused by accidently adding the Source file as a dependency in other-modules in the cabal-file of the project ... that caused all the trouble.

Upvotes: 4

Bartek Banachewicz
Bartek Banachewicz

Reputation: 39370

hs-source-dirs: ., src comes to mind as a fast fix.

That's what my projects use, and I generate my cabal files automatically (so I suppose that's the default).

Upvotes: 3

Related Questions