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

Feature request: absolute paths in ghc errors #6670

Open
symbiont-sam-halliday opened this issue Apr 7, 2020 · 9 comments
Open

Feature request: absolute paths in ghc errors #6670

symbiont-sam-halliday opened this issue Apr 7, 2020 · 9 comments
Labels
re: error-message Concerning error messages delivered to the user type: enhancement

Comments

@symbiont-sam-halliday
Copy link

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 of hs-source-dirs prior to invoking ghc.

@phadej
Copy link
Collaborator

phadej commented Apr 7, 2020

This is a perfect issue to solve after #6667. Before that I'm not brave enough to change anything related to paths.

@DanielG
Copy link
Collaborator

DanielG commented Apr 7, 2020

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.

@symbiont-sam-halliday
Copy link
Author

@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.

@symbiont-sam-halliday
Copy link
Author

symbiont-sam-halliday commented Sep 11, 2020

@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.

@jacereda
Copy link

I'm also interested in this feature. I also noticed https://gitlab.haskell.org/ghc/ghc/-/issues/15680

@jacereda
Copy link

Emacs 27.1 also has compilation-transform-file-match-alist that can serve as a workaround sometimes.

@symbiont-sam-halliday
Copy link
Author

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.

@newhoggy
Copy link

Is it possible that MAX_PATH restrictions on Windows had a role to play in keeping relative directories in stack?

@ulysses4ever ulysses4ever added type: enhancement re: error-message Concerning error messages delivered to the user labels Nov 20, 2022
@ulysses4ever
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
re: error-message Concerning error messages delivered to the user type: enhancement
Projects
None yet
Development

No branches or pull requests

6 participants