Skip to content

GHCi has difficulty when "-main-is Module.main" is specified in ghc-options #1606

@mgsloan

Description

@mgsloan

The issue is that it expects the main-is: cabal field to be a Main module. When it isn't, we get duplicate modules. Take, for example ndmitchell/ghcid:

mgsloan@computer:~/oss/ndmitchell/ghcid$ stack ghci --test
ghcid-0.5: Test running disabled by --no-run-tests flag.

* * * * * * * *
The main module to load is ambiguous. Candidates are: 
1. Package `ghcid' component exe:ghcid with main-is file: /home/mgsloan/oss/ndmitchell/ghcid/src/Ghcid.hs
2. Package `ghcid' component test:ghcid_test with main-is file: /home/mgsloan/oss/ndmitchell/ghcid/src/Test.hs
You can specify which one to pick by: 
 * Specifying targets to stack ghci e.g. stack ghci ghcid:exe:ghcid
 * Specifying what the main is e.g. stack ghci --main-is ghcid:exe:ghcid
 * Choosing from the candidate above [1..2]
* * * * * * * *

Specify main module to use (press enter to load none): 1
Loading main module from cadidate 1, --main-is /home/mgsloan/oss/ndmitchell/ghcid/src/Ghcid.hs

The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: ghcid
GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
unknown option: 'c'

<no location info>:
    module ‘main@main:Ghcid’ is defined in multiple files: /home/mgsloan/oss/ndmitchell/ghcid/src/Ghcid.hs
                                                           /home/mgsloan/oss/ndmitchell/ghcid/src/Ghcid.hs
Failed, modules loaded: none.

<no location info>:
    Could not find module ‘Ghcid’
    It is not a module in the current program, or in any known package.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions