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

ghcmod "Could not load module" for test file #1362

Closed
freeman42x opened this issue Aug 17, 2019 · 4 comments
Closed

ghcmod "Could not load module" for test file #1362

freeman42x opened this issue Aug 17, 2019 · 4 comments

Comments

@freeman42x
Copy link

Getting the following ghcmod error message in the test file:

Could not load module ‘Hedgehog.Range’
It is a member of the hidden package ‘hedgehog-0.6.1’.
Perhaps you need to add ‘hedgehog’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.

If I open a Lib file HIE works fine without any errors.

Using GHC 8.6.4
Issue can be reproduced both with Atom and VSCode

To reproduce you can git clone this project: https://github.com/fairy-tale-agi-solutions/fairy-tale-artificial-general-intelligence-solutions/tree/master/Sources/Razvan%20Flavius%20Panda/Haskell/artificial-general-intelligence

At SHA: 758129122541c2f2f0a4f19a1e70e413543fa72e

And open the test/Spec.hs file to see the issue.

@freeman42x
Copy link
Author

For now I used the workaround of adding the test packages to the library part of the cabal file also:

  • hedgehog
  • hedgehog-fn

ghcmod sees the modules then and HIE works.

@willisplummer
Copy link

I'm running into something I think is similar on a stack project --

File:     ./test/GetMaxFromMapSpec.hs
Range:    4:7-4:17
Source:   not found
Severity: DsError
Message: 
  Could not find module ‘Test.Hspec’
  It is not a module in the current program, or in any known package.

here's my package yaml:

name:                friendface
version:             0.1.0.0
github:              "githubuser/friendface"
license:             BSD3
author:              "Author name here"
maintainer:          "[email protected]"
copyright:           "2019 Author name here"

extra-source-files:
- README.md
- ChangeLog.md

# Metadata used when publishing your package
# synopsis:            Short description of your package
# category:            Web

# To avoid duplicated efforts in documentation and dealing with the
# complications of embedding Haddock markup inside cabal files, it is
# common to point users to the README.md file.
description:         Please see the README on GitHub at <https://github.com/githubuser/friendface#readme>

dependencies:
- aeson
- base >= 4.7 && < 5
- bytestring
- cassava
- containers
- servant
- servant-server
- text
- time
- vector
- wai
- warp

library:
  source-dirs: src

executables:
  friendface-exe:
    main:                Main.hs
    source-dirs:         app
    ghc-options:
    - -threaded
    - -rtsopts
    - -with-rtsopts=-N
    dependencies:
    - friendface

tests:
  friendface-test:
    defaults: hspec/hspec@master
    # main:                Spec.hs
    # source-dirs:         test
    # ghc-options:
    # - -threaded
    # - -rtsopts
    # - -with-rtsopts=-N
    dependencies:
    - friendface

@jneira
Copy link
Member

jneira commented Sep 29, 2019

I am experiencing it open haskell-ide-engine itself (stack based) with vscode in windows 10:

{
	"resource": "/D:/dev/ws/haskell/haskell-ide-engine/test/functional/FunctionalCodeActionsSpec.hs",
	"owner": "Haskell HIE (haskell-ide-engine)",
	"severity": 8,
	"message": "Could not load module `Control.Applicative.Combinators'\nIt is a member of the hidden package `parser-combinators-1.1.0'.\nPerhaps you need to add `parser-combinators' to the build-depends in your .cabal file.\nUse -v to see a list of the files searched for.",
	"source": "ghcmod",
	"startLineNumber": 11,
	"startColumn": 1,
	"endLineNumber": 11,
	"endColumn": 49
}

and 4 more similar errors

@fendor
Copy link
Collaborator

fendor commented Dec 20, 2019

Should be resolved now. For different components, having different dependencies works. Resolved by #1126

@fendor fendor closed this as completed Dec 20, 2019
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

4 participants