Ghcide: Cradle for autogenerated Paths_* files

Created on 20 May 2020  路  9Comments  路  Source: haskell/ghcide

I'm not sure if this is the right place for this issue, so sorry in advance if it isn't!

When using the autogenerated Paths_ module with an explicit cradle ghcide understandably complains that the .stack-work/blablabla/autogen/Paths_<project>.hs file matches no prefix in the cradle.

For now I just hardcoded the path to the Paths_<project>.hs file in my hie.yaml and gave it some arbitrary component to load (<project>:lib), but I don't think this is intended or great UX (as it is an artifact of compilation - it contains build directories internal to stack/cabal in its path)

bug setup

Most helpful comment

Maybe a relatively simple workaround could be

path: .stack-work/
component: myproject:lib

In the hope all generated modules under .stack-work will be loaded by that component.
I have to test it, though.

Confirmed a hie.yaml like this:

cradle:
  stack:
    - path: "./.stack-work"
      component: "stack-test:lib"
    - path: "./app"
      component: "stack-test:exe:stack-test"
    - path: "./src"
      component: "stack-test:lib"
    - path: "./test"
      component: "stack-test:test:stack-test-test"

do the workaround

All 9 comments

This is a bug in stack not listing the Paths_ module in the targets for the component.

Do you know of a way to get the targets for a given component, so I can file a proper bug report to stack?

For implicit-hie I remove modules found in autogen-modules from other-modules.

In light of this that seems like the wrong behavior?

Maybe a relatively simple workaround could be

path: .stack-work/
component: myproject:lib

In the hope all generated modules under .stack-work will be loaded by that component.
I have to test it, though.

Confirmed a hie.yaml like this:

cradle:
  stack:
    - path: "./.stack-work"
      component: "stack-test:lib"
    - path: "./app"
      component: "stack-test:exe:stack-test"
    - path: "./src"
      component: "stack-test:lib"
    - path: "./test"
      component: "stack-test:test:stack-test-test"

do the workaround

Maybe a dumb question: why not use a multi-cradle + the none cradle for ./.stack-work directory? AFAIU you associate .stack-work with the lib component, but is that necessary?

The cradle should be able to load the Paths_project.hs module cause it could be used in regular modules. As it does not have any dependencies, it could be loaded with a plain call to ghc (not tested) but the lib component can handle too. Not sure if the direct cradle, which only uses ghc is supported by hls/ghcide.

This can now be closed due to https://github.com/haskell/ghcide/issues/819, right?

Yeah, for completeness:

  • the described workaround is not longer needed for cabal (just tested it) and it does not work for stack with lastest hls/ghcide
  • once a new stack version is released hls will be able to handle those modules directly for stack too

Happily, a release candidate for stack (2.5) just popped up with the patch!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

emilypi picture emilypi  路  8Comments

domenkozar picture domenkozar  路  3Comments

istathar picture istathar  路  8Comments

turion picture turion  路  7Comments

pepeiborra picture pepeiborra  路  9Comments