Closed konn closed 4 months ago
Oof yeah, that's a bug. The excluded files should be relative to the Cabal file that they're referenced in. This line will have to change to incorporate the root
:
This wasn't caught by the tests because all the ones for the --exclude
flag use STDIN, so the Cabal file's directory is the same as the CWD. Another test should be added like this one:
I'd be happy to accept a PR to fix this issue. It may take me a while to get around to it.
For now, cabal-gild shipped with HLS is slightly older and does not support exclusion mechanism
If I am not mistaken, HLS doesn't ship with cabal-gild
and uses the binary on the $PATH
. Only the tests pull in cabal-gild
in HLS. So, perhaps this is another issue.
Maybe HLS runs the cabal-gild
command from some other directory, perhaps even a temporary one?
Should be the directory of the .cabal
file: https://github.com/haskell/haskell-language-server/blob/master/plugins/hls-cabal-gild-plugin/src/Ide/Plugin/CabalGild.hs#L77
For now, cabal-gild shipped with HLS is slightly older and does not support exclusion mechanism
If I am not mistaken, HLS doesn't ship with
cabal-gild
and uses the binary on the$PATH
. Only the tests pull incabal-gild
in HLS. So, perhaps this is another issue.
Ah, it seems that I use the current released version of Haskell extension for VSCode and it does not support haskell.cabalFormattingProvider
item, which makes HLS of course ignores cabal-gild
pragma as it uses cabal-fmt as a formatter! So please ignore the claim about the HLS.
@tfausak I've just filed PR to fix this issue: #73
I'm using cabal-gild on monorepo, using
find
command combined withcabal-gild --io
to format everything. For now, cabal-gild shipped with HLS is slightly older and does not support exclusion mechanism, so I use the following command on every save:This work as expected as long as
--exclude
isn't used in cabal files. OTOH, if one uses relative path in--exclude
, then cabal-gild resolves the path relative to current working directory, not relative to*.cabal
files.For example, suppose we have
project-core/project-core.cabal
with the following contents:If one invoke cabal-gild inside
project-a
directory, it just emits an emptyother-modules
. On the other hand, if one uses the abovefind
-script in the monorepo root, it emits:If one changes the exclude relative to monorepo root, it works as expected:
As cabal resolves relative paths according to
*.cabal
file, I think it would make sense to paths to be resolved relative to cabal files.