Skip to content

Commit

Permalink
Better explain the message changes
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Dec 12, 2024
1 parent 61f53c6 commit 33d2fcd
Showing 1 changed file with 69 additions and 4 deletions.
73 changes: 69 additions & 4 deletions changelog.d/pr-10546
Original file line number Diff line number Diff line change
@@ -1,9 +1,74 @@
---
synopsis: Add an Ord instance for ProjectConfigPath
synopsis: Deduplicate "using configuration from" message
packages: [cabal-install-solver]
prs: 10546
---

Add an `Ord` instance for `ProjectConfigPath` that sorts URIs after local paths
and longer paths after shorter ones. Deduplicate the printing of "Configuration is
affected by the following files" messages.
## Using Configuration From Message Changes

Deduplicates and sorts the list of configuration files and URIs printed with the
"using configuration from" messages. This is the message shown when there's a
build failure. We can trigger that message by using a non-existant package in
the project, "no-pkg-dir".

If an import is repeated in a `.project` or `.config` file it only imported once
but if the same import is made from an imported file then it is repeated in the
message.

* The test set up:

```
$ cat cabal.project
packages: no-pkg-dir
import: extra.config
import: extra.config
import: very-extra.config
import: very-extra.config
import: https://www.stackage.org/lts-21.25/cabal.config
import: https://www.stackage.org/lts-21.25/cabal.config

$ cat extra.config
import: https://www.stackage.org/lts-21.25/cabal.config
import: https://www.stackage.org/lts-21.25/cabal.config

$ cat very-extra.config
import: https://www.stackage.org/lts-21.25/cabal.config
import: https://www.stackage.org/lts-21.25/cabal.config
```

* Before the fix:

```
$ ~/.ghcup/bin/cabal-3.12.1.0 build all --dry-run
When using configuration from:
- cabal.project
- extra.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- https://www.stackage.org/lts-21.25/cabal.config
- very-extra.config
The following errors occurred:
- The package location 'no-pkg-dir' does not exist.
```

* After the fix:

```
$ cabal build all --dry-run
When using configuration from:
- cabal.project
- extra.config
- very-extra.config
- https://www.stackage.org/lts-21.25/cabal.config
The following errors occurred:
- The package location 'no-pkg-dir' does not exist.
```

## Ord ProjectConfigPath Instance Changes

Adds a custom `Ord` instance for `ProjectConfigPath` that sorts URIs after local
file paths and longer file paths after shorter ones as measured by the number of
path segments. If still equal, then sorting is lexical. The project itself, a
single element root path, compared to any of the configuration paths it imports,
should always sort first. Comparing one project root path against another is
done lexically.

0 comments on commit 33d2fcd

Please sign in to comment.