graphmod icon indicating copy to clipboard operation
graphmod copied to clipboard

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

Open matobet opened this issue 2 years ago • 0 comments

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.

matobet avatar Aug 11 '22 18:08 matobet