Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not load module ‘Test’ It is a member of the hidden package ‘hie-error-0.1.0.0’. #347

Closed
Congee opened this issue Aug 22, 2020 · 7 comments
Labels
component: hie-bios type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@Congee
Copy link

Congee commented Aug 22, 2020

I can reproduce it with a simple project generated by cabal init. cabal build succeeds, but hie stumbles.

Project structure:

.
├── CHANGELOG.md
├── hie-error.cabal
├── Main.hs
├── Setup.hs
└── src
    └── Test.hs

./Main.hs

module Main where

import Test  -- Could not load module ‘Test’ It is a member of the hidden package ‘hie-error-0.1.0.0’. You can run ‘:set -package hie-error’ to expose it.

main :: IO ()
main = putStrLn "Hello, Haskell!"

./src/Test.hs

module Test where

./hie-error.cabal

cabal-version:       >=1.10
-- Initial package description 'hie-error.cabal' generated by 'cabal init'.
--   For further documentation, see http://haskell.org/cabal/users-guide/

name:                hie-error
version:             0.1.0.0
-- synopsis:
-- description:
-- bug-reports:
-- license:
license-file:        LICENSE
author:              Congee
maintainer:          ...
-- copyright:
-- category:
build-type:          Simple
extra-source-files:  CHANGELOG.md

library
  exposed-modules:     Test
  hs-source-dirs:      src
  default-language:    Haskell2010
  build-depends:       base

executable hie-error
  main-is:             Main.hs
  -- other-modules:
  -- other-extensions:
  build-depends:       base >=4.13 && <4.14, hie-error
  -- hs-source-dirs:
  default-language:    Haskell2010

Nothing interesting in the hie output

2020-08-22 18:18:15.2609133 [ThreadId 77] - Consulting the cradle for "/tmp/hie-error/Main.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/tmp/hie-error", cradleOptsProg = CradleAction: Cabal}
> Resolving dependencies...
> Build profile: -w ghc-8.8.4 -O1
> In order, the following will be built (use -v for more details):
>  - hie-error-0.1.0.0 (lib) (configuration changed)
>  - hie-error-0.1.0.0 (exe:hie-error) (configuration changed)
> Configuring library for hie-error-0.1.0.0..
> Warning: The 'license-file' field refers to the file 'LICENSE' which does not
> exist.
> Preprocessing library for hie-error-0.1.0.0..
> Building library for hie-error-0.1.0.0..
> [1 of 1] Compiling Test             ( src/Test.hs, /tmp/hie-error/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hie-error-0.1.0.0/build/Test.o )
> Configuring executable 'hie-error' for hie-error-0.1.0.0..
> Warning: The package has an extraneous version range for a dependency on an
> internal library: hie-error -any && ==0.1.0.0. This version range includes the
> current package but isn't needed as the current package's library will always
> be used.
> Warning: The 'license-file' field refers to the file 'LICENSE' which does not
> exist.

However, Putting ./src/Test.hs in the project root makes hie happy.

cabal: 3.2.0.0
ghc: 8.8.4
hie: b6c1551 Fri Aug 21 16:04:47 2020 +0100

I believe this issue differs from #299

@jneira jneira added component: hie-bios type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. status: needs repro labels Aug 24, 2020
@fendor
Copy link
Collaborator

fendor commented Sep 9, 2020

I can not reproduce on NixOS. Can you invoke haskell-language-server --debug Main.hs and paste the logs here?

What is your cabal version?

@Congee
Copy link
Author

Congee commented Sep 9, 2020

Thank you for taking a look. I'm using
ghc 8.8.4, base-4.13.0.0, cabal 3.2.0.0,
haskell-language-server is up-to-date using ec82770

And, I haven't added hie.yml yet

logs for 8.8.4

/tmp/hie-error$ haskell-language-server-8.8.4 --debug app/Main.hs
haskell-language-server version: 0.4.0.0 (GHC: 8.8.4) (PATH: /home/congee/.cabal/bin/haskell-language-server-8.8.4)
(haskell-language-server)Ghcide setup tester in /tmp/hie-error.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Tool versions found on the $PATH
cabal:          3.2.0.0
stack:          2.3.3
ghc:            8.8.4


Step 1/4: Finding files to test in /tmp/hie-error
Found 1 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
[INFO] Consulting the cradle for "/tmp/hie-error/app/Main.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/tmp/hie-error", cradleOptsProg = CradleAction: Cabal}
> cabal: Unknown target '/tmp/hie-error/app/Main.hs'.
> The package hie-error has no file target 'app/Main.hs'.
>
>
File:     /tmp/hie-error/app/Main.hs
Hidden:   no
Range:    1:0-2:0
Source:   cradle
Severity: DsError
Message:
  Failed to parse result of calling cabal

  cabal: Unknown target '/tmp/hie-error/app/Main.hs'.
  The package hie-error has no file target 'app/Main.hs'.




[INFO] finish: User TypeCheck (took 0.04s)Files that failed:

 * /tmp/hie-error/app/Main.hs

Completed (0 files worked, 1 file failed)

logs for 8.10.2

/tmp/hie-error$ haskell-language-server-8.10.2 --debug app/Main.hs
haskell-language-server version: 0.4.0.0 (GHC: 8.10.2) (PATH: /home/congee/.cabal/bin/haskell-language-server-8.10.2)
(haskell-language-server)Ghcide setup tester in /tmp/hie-error.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Tool versions found on the $PATH
cabal:          3.2.0.0
stack:          2.3.3
ghc:            8.10.2


Step 1/4: Finding files to test in /tmp/hie-error
Found 1 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
[INFO] Consulting the cradle for "/tmp/hie-error/app/Main.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/tmp/hie-error", cradleOptsProg = CradleAction: Cabal}
> cabal: Unknown target '/tmp/hie-error/app/Main.hs'.
> The package hie-error has no file target 'app/Main.hs'.
>
>
File:     /tmp/hie-error/app/Main.hs
Hidden:   no
Range:    1:0-2:0
Source:   cradle
Severity: DsError
Message:
  Failed to parse result of calling cabal

  cabal: Unknown target '/tmp/hie-error/app/Main.hs'.
  The package hie-error has no file target 'app/Main.hs'.




[INFO] finish: User TypeCheck (took 0.02s)Files that failed:

 * /tmp/hie-error/app/Main.hs

Completed (0 files worked, 1 file failed)

No luck either with hie.yml generated by gen-hie

cradle:
  cabal:
    - path: "src"
      component: "lib:hie-error"

    - path: "app/Main.hs"
      component: "hie-error:exe:hie-error"

@Congee
Copy link
Author

Congee commented Sep 9, 2020

BTW, do all cool kids use NixOS nowadays? 🤔

@jneira
Copy link
Member

jneira commented Sep 9, 2020

if you like yak shaving you have two main options: nixos or Windows 😝

@fendor
Copy link
Collaborator

fendor commented Sep 9, 2020

Haskell and NixOS users have indeed a huge overlap.
Without hie.yaml, I can explain: haskell/cabal#6622

With hie.yaml it should work, afaict, can you paste logs of the execution with hie.yaml?

@Congee
Copy link
Author

Congee commented Sep 9, 2020

After renaming hie.yml to hie.yaml, the haskell-language-server worked.

@Congee
Copy link
Author

Congee commented Sep 9, 2020

I figured out the problem! That error is not from haskell-language-server but from another plugin https://github.com/dense-analysis/ale

@Congee Congee closed this as completed Sep 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hie-bios type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

3 participants