Open symbiont-sam-halliday opened 4 years ago
This is a perfect issue to solve after https://github.com/haskell/cabal/issues/6667. Before that I'm not brave enough to change anything related to paths.
You might be interrested in my PR #6196 which addresses this issue using Entering/Leaving
messages mentioning the directory Cabal is being invoked in, similar to how recursive Make deals with this problem.
@DanielG thanks! That looks interesting. I think it'd be a lot cleaner generally if more things used absolute paths. Parsing contextual information seems like it might be impossible for many tools, e.g. a terminal that is just doing filename detection and linking.
@phadej if I wanted to make just this one directory absolute, do you know which line of code I should change? It's the only one I care about since it impacts ghc error messages.
I'm also interested in this feature. I also noticed https://gitlab.haskell.org/ghc/ghc/-/issues/15680
Emacs 27.1 also has compilation-transform-file-match-alist
that can serve as a workaround sometimes.
It seems bizarre to me that stack implemented this as a post-processor of the ghc output, instead of just making the directory absolute before invoking ghc. As a proof of concept that this is all that is needed, I manually converted all my source locations to absolute paths and ghc did what I wanted. Of course, I can't commit that kind of change to my project's repo.
Is it possible that MAX_PATH
restrictions on Windows had a role to play in keeping relative directories in stack
?
Most of diagnostics containing paths comes from GHC, so it should be fixed there. I guess I don’t understand how you see it being done in cabal, @symbiont-sam-halliday, could you explain in more detail?
ghc will report errors and warnings in files relative to the
hs-source-dirs
that is declared in the.cabal
file. This typically results in minimal output relative to the location of the.cabal
file.However, there are many workflows where this can result in problems, especially if the user invokes
cabal build
from a different directory which is common in multi-project builds.It would be good if there was a
cabal.project{.local}
option made available that caused cabal to construct the absolute path ofhs-source-dirs
prior to invokingghc
.