Haskell-language-server: How to work with auto generated Paths_xxx module?

Created on 29 Sep 2020  Â·  8Comments  Â·  Source: haskell/haskell-language-server

Subject of the issue

I'm trying to introduce data-files to my project. In order to access files in data-dir, an auto generated module Paths_xxx (xxx is the project name) is required to be imported to the module. However, it seems that hls can find this auto generated module at .stack-work/dist/.../.../.../build/autogen/Paths_xxx.hs, but doesn't know how to deal with that. So, I use multi cradle to let hls ignore .stack-work dir, but hls will complain that the module which uses getDataFileName will not be loaded because of this missing function, and those prevent a series of modules of the project won't be loaded as well.

Your environment

  • Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools

    • This command is available since version >= 0.4.0.0

haskell-language-server version: 0.4.0.0 (GHC: 8.10.2) (PATH: /usr/bin/haskell-language-server-8.10.2) (GIT hash: 0a18edde24923251a148cbbc0ae993a6aac83b9c)
Tool versions found on the $PATH
cabal:          3.2.0.0
stack:          2.3.1
ghc:            8.10.2
  • Which lsp-client do you use

    • Neovim, emacs, VS Codium, etc...

vscode

  • Describe your project (alternative: link to the project)

https://github.com/berberman/arch-hs

Steps to reproduce

Just open the project and load it.

Expected behaviour

hls knows what Paths_arch_hs is.

Actual behaviour

Module ‘Paths_arch_hs’ does not export ‘getDataFileName’

Actually, hls didn't load this module.

Include debug information

Execute in the root of your project the command haskell-language-server --debug . and paste the logs here:



Debug output:

(haskell-language-server)Ghcide setup tester in /home/berberman/Desktop/arch-hs.
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.1
ghc:        8.10.2


Step 1/4: Finding files to test in /home/berberman/Desktop/arch-hs
Found 23 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 "/home/berberman/Desktop/arch-hs/src/Distribution/ArchHs/Utils.hs"
[INFO] Using interface files cache dir: /home/berberman/.cache/ghcide/main-e1a0f5a15b1a5172633bf00dda6772d0895497c6
[INFO] Making new HscEnv[main]
[INFO] Consulting the cradle for "/home/berberman/Desktop/arch-hs/submit/Submit.hs"
[INFO] Using interface files cache dir: /home/berberman/.cache/ghcide/main-e721920226c057787f73c07ca140a8b0d7c87126
[INFO] Using interface files cache dir: /home/berberman/.cache/ghcide/main-e721920226c057787f73c07ca140a8b0d7c87126
[INFO] Making new HscEnv[main,main]
[INFO] Consulting the cradle for "/home/berberman/Desktop/arch-hs/Setup.hs"
File:     /home/berberman/Desktop/arch-hs/Setup.hs
Hidden:   no
Range:    1:0-2:0
Source:   cradle
Severity: DsError
Message: 
  Multi Cradle: No prefixes matched
  pwd: /home/berberman/Desktop/arch-hs
  filepath: /home/berberman/Desktop/arch-hs/Setup.hs
  prefixes:
  ("./app",Stack {component = Just "arch-hs:exe:arch-hs"})
  ("./diff",Stack {component = Just "arch-hs:exe:arch-hs-diff"})
  ("./submit",Stack {component = Just "arch-hs:exe:arch-hs-submit"})
  ("./src",Stack {component = Just "arch-hs:lib"})
[INFO] Consulting the cradle for "/home/berberman/Desktop/arch-hs/diff/Diff.hs"
[INFO] Using interface files cache dir: /home/berberman/.cache/ghcide/main-6c7ba429178a4583708cb933618cabb19b7c5d07
[INFO] Using interface files cache dir: /home/berberman/.cache/ghcide/main-6c7ba429178a4583708cb933618cabb19b7c5d07
[INFO] Using interface files cache dir: /home/berberman/.cache/ghcide/main-6c7ba429178a4583708cb933618cabb19b7c5d07
[INFO] Making new HscEnv[main,main,main]
[INFO] Consulting the cradle for "/home/berberman/Desktop/arch-hs/Setup.hs"
[INFO] Consulting the cradle for "/home/berberman/Desktop/arch-hs/app/Main.hs"
[INFO] Using interface files cache dir: /home/berberman/.cache/ghcide/main-3eed09a1cc1ce8c9255decb48e008673712025ba
[INFO] Using interface files cache dir: /home/berberman/.cache/ghcide/main-3eed09a1cc1ce8c9255decb48e008673712025ba
[INFO] Using interface files cache dir: /home/berberman/.cache/ghcide/main-3eed09a1cc1ce8c9255decb48e008673712025ba
[INFO] Using interface files cache dir: /home/berberman/.cache/ghcide/main-3eed09a1cc1ce8c9255decb48e008673712025ba
[INFO] Making new HscEnv[main,main,main,main]
[INFO] Consulting the cradle for "/home/berberman/Desktop/arch-hs/Setup.hs"
[INFO] Consulting the cradle for "/home/berberman/Desktop/arch-hs/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.0.0/build/autogen/Paths_arch_hs.hs"
File:    
  /home/berberman/Desktop/arch-hs/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.0.0/build/autogen/Paths_arch_hs.hs
Hidden:   no
Range:    1:0-2:0
Source:   cradle
Severity: DsError
Message: 
  Multi Cradle: No prefixes matched
  pwd: /home/berberman/Desktop/arch-hs
  filepath:
  /home/berberman/Desktop/arch-hs/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.0.0/build/autogen/Paths_arch_hs.hs
  prefixes:
  ("./app",Stack {component = Just "arch-hs:exe:arch-hs"})
  ("./diff",Stack {component = Just "arch-hs:exe:arch-hs-diff"})
  ("./submit",Stack {component = Just "arch-hs:exe:arch-hs-submit"})
  ("./src",Stack {component = Just "arch-hs:lib"})
[INFO] finish: User TypeCheck (took 0.89s)
Files that failed:
 * /home/berberman/Desktop/arch-hs/Setup.hs
 * /home/berberman/Desktop/arch-hs/src/Distribution/ArchHs/Aur.hs
 * /home/berberman/Desktop/arch-hs/src/Distribution/ArchHs/Community.hs
 * /home/berberman/Desktop/arch-hs/src/Distribution/ArchHs/Core.hs
 * /home/berberman/Desktop/arch-hs/src/Distribution/ArchHs/Exception.hs
 * /home/berberman/Desktop/arch-hs/src/Distribution/ArchHs/Hackage.hs
 * /home/berberman/Desktop/arch-hs/src/Distribution/ArchHs/Name.hs
 * /home/berberman/Desktop/arch-hs/src/Distribution/ArchHs/Internal/NameLoader.hs

Completed (15 files worked, 8 files failed)

stack can-workaround ghcide needs confirmation question

Most helpful comment

I am afraid that the workaround is not applicable to last version of hls and stack, until a new stack version is released, see https://github.com/haskell/ghcide/issues/819
There you could find another workaround (sigh)

All 8 comments

A workaround is to set any cradle you like (e.g. your library) for the Paths_ stuff, because they don't really depend on anything custom. Related: https://github.com/haskell/ghcide/issues/574

I am afraid that the workaround is not applicable to last version of hls and stack, until a new stack version is released, see https://github.com/haskell/ghcide/issues/819
There you could find another workaround (sigh)

@berberman the workaround could be applied with last stack version, could you confirm it works for you?

I was under the impression that you no longer need to do any workarounds with the latest stack? Is this perhaps not the case?

mmm, good point, i have to check if the workaround (set a direct cradle for .stack-work) is needed for:

  • open a file that imports the Path_ module (i think it will be not needed)
  • open the Path_ module itself (maybe it is, although it is not a big deal)

@berberman the workaround could be applied with last stack version, could you confirm it works for you?

Sorry, I no longer use these autogenerated modules, and I totally embrace cabal XD
I could try this by creating a new project

@berberman dont worry i'll check myself, thanks anyways

@googleson78 you were right, the workaround in no longer needed and you can load the Path_pkgname.hs file in hls without it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alanz picture alanz  Â·  4Comments

danbroooks picture danbroooks  Â·  3Comments

expipiplus1 picture expipiplus1  Â·  3Comments

alanz picture alanz  Â·  4Comments

mouse07410 picture mouse07410  Â·  4Comments