Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

ghcmod cannot find module(s) #644

Closed
pascalpoizat opened this issue Jun 20, 2018 · 3 comments
Closed

ghcmod cannot find module(s) #644

pascalpoizat opened this issue Jun 20, 2018 · 3 comments
Milestone

Comments

@pascalpoizat
Copy link

First of all, thanks a lot for HIE that is now my Haskell engine in VSC.
Here is an issue I observe when I have project with a main source directory + a test one.

Summary

I have a project built with several targets (library, executable, test-suite).
The "main" sources are in src, while the tests are in test.
All is ok with the source files but on test files modules are not found.

How to reproduce

git clone https://github.com/pascalpoizat/veca-haskell
cd veca-haskell
gco multiple-component-instances
open . -a Visual\ Studio\ Code

Then in VSC open any file in the test directory (eg EventsTests.hs).

There is an error on the two Tasty imports.

[ghcmod]
Could not find module ‘Test.Tasty’
Use -v to see a list of the files searched for.

Possible solution

This could be close to an issue I had when using Haskero,
https://gitlab.com/vannnns/haskero/issues/30,
the solution being a button to select the target (or "all targets"),
https://gitlab.com/vannnns/haskero/merge_requests/1.

Environment

~/hie
hie          hie-8.2      hie-8.2.1    hie-8.2.2    hie-8.4      hie-8.4.2    hie-8.4.3    hie-wrapper
❯ hie --version
Version 0.2.0.0, Git revision 374da0753b4c126eb71175284f0b6e551674abb6 (1515 commits) x86_64 ghc-8.4.3

Stack file: https://github.com/pascalpoizat/veca-haskell/blob/multiple-component-instances/stack.yaml

Cabal file: https://github.com/pascalpoizat/veca-haskell/blob/multiple-component-instances/veca-haskell.cabal

@alanz
Copy link
Collaborator

alanz commented Jun 20, 2018

The project works according to what has been configured.

So until you run stack test, or cabal configure --enable-tests it will not be able to see the test files.

Also, if you do this, you are likely to bump into #620 . The only workaround at the moment is to only have one main file open in the IDE at a time.

@pascalpoizat
Copy link
Author

Thanks @alanz with stack test (or my "run" command, stack clean; stack test :veca-haskell-test --ta "--html result.html" --coverage --haddock --no-haddock-deps) it works fine.

Therefore I propose to close this issue.

I can confirm that I have now issue #620.

Got error while processing diagnostics: <no location info>: error: module ‘veca-haskell-1.0.1.0:Main’ is defined in multiple files: /private/var/folders/ww/4qr74bvn12v4049mw7mxvzq80000gn/T/ghc-mod4121/Main4118-4.hs /private/var/folders/ww/4qr74bvn12v4049mw7mxvzq80000gn/T/ghc-mod4119/Spec4118-2.hs

(so I'll follow this issue)

But anyway, it is so amazing all that is already in HIE. Thanks !
I will have to add a line for HIE in this project https://github.com/rainbyte/haskell-ide-chart based on what I experimented here rainbyte/haskell-ide-chart#22

@freckletonj
Copy link

I had the same issue, I needed to clean out .stack-work/ and run stack test #1006 (comment)

rm -r .stack-work
stack test # I think I needed to run this before ghcmod could pick up the test targets
emacs

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants