Skip to content

Multiple hs-source-dirs in executable stanza cause failure when looking for non-existing file #41

@matobet

Description

@matobet

I have in my Cabal file an executable like this:

executable my-app
    -- ....
    hs-source-dirs:
        src/app src/common src/other

    main-is:        Main.hs

And running graphmod on this cabal project will result in:

graphmod: src/common/Main.hs: openFile: does not exist (No such file or directory)

The Main.hs file is in fact located only in one of the directories (namely src/app/Main.hs) but it seems as graphmod is trying to also look for src/common/Main.hs and (if I remove src/common from hs-source-dirs) also for src/other/Main.hs.

By a quick glance this seems to be caused by https://github.com/yav/graphmod/blob/master/src/Graphmod/CabalSupport.hs#L80 indiscriminately combining the main module file with each of the hs-source-dirs instead of looking for the (usually) only one that exists.

This is a problem because instead of ignoring such non-existing file this will error out and graphmod will produce no output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions