Wrong relative paths in error messages when building a multi-package project
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
**Describe the bug**
We have a multi-package repository
Packages are sub-directories at project root.
```
packages:
plutus-benchmark
plutus-conformance
plutus-core
...
```
Usually I am building inside the *project's root directory*.
```bash
cd clonedrepo/plutus/
cabal build all
cabal build plutus-core # for a specific package
```
The problem is that in case GHC compilation fails, the GHC error messages contain paths
not relative to where I am building at the moment (that is the project's root directory).
The path is relative to the specific package under compilation and not relative to `$PWD`
**To Reproduce**
As an example after editing a file,
```
plutus-core/src/PlutusCore/Data.hs:12:29: error:
Module ‘Codec.CBOR.Decoding’ does not export ‘Decoderm’
|
12 | import Codec.CBOR.Decoding (Decoderm,)
| ^^^^^^^^
```
The path `plutus-core/src/PlutusCore/Data.hs:12:29` is wrong relative to my `$PWD` (project root) that I am currently building in.
**Expected behavior**
I would expect that Cabal and GHC would print the correct path relative to where I am building at the moment, which is
`plutus-core/plutus-core/src/PlutusCore/Data.hs`
It seems that the package parent directory is omitted from the error messages.
It "feels" like `cabal-install` is `cd`ing to the package, building it as a normal Cabal package, then `cd`ing back out directory, roughly like:
```
cd ./plutus-core/
cabal build
cd ../
```
The problem arises when needing to navigate to these errors source spans. They do not reflect the `$PWD` that is returned after cabal is aborted/completed. Editors such as emacs (and its compilation mode) have difficulty figuring out the correct path to navigate to.
**System information**
- Operating system
- `cabal-3.12.1`, `ghc-9.6.7` versions
**Additional context**
I searched in GHC for flag that can print **absolute filepaths** under compilation. But it does not seem to be such an option: https://downloads.haskell.org/ghc/latest/docs/users_guide/flags.html#verbosity-options
Contributor guide
Assessment
This issue has not been assessed yet.