Error UX improvement wrt `index-state` and newer dependencies
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
I just burned about a half hour trying to figure out why `cabal build` was failing to find `fourmolu-0.7.0.1` when trying to build `hls-fourmolu-plugin`. Turns out, `cabal` was jumping up three directories and reading the `index-state` from a `cabal.project`.
It'd be nice if `cabal` could notify me that something like that may be going on. The current behavior is something like:
- I am trying to build `foo-2` which depends on `bar >= 3`
- `cabal` does dependency resolution using the `index-state`. It finds `bar-2`, but is unable to find a *new enough* version of the library.
- `cabal` prints an error saying it can't satisfy the dependencies.
Here's the build output:
```
λ ~/Projects/haskell-language-server/plugins/hls-fourmolu-plugin/ mattp/fourmolu-support cabal build
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: hls-fourmolu-plugin-1.0.3.0 (user goal)
[__1] next goal: fourmolu (dependency of hls-fourmolu-plugin)
[__1] rejecting: fourmolu-0.6.0.0 (conflict: hls-fourmolu-plugin =>
fourmolu==0.7.0.1)
[__1] skipping: fourmolu-0.5.0.1, fourmolu-0.5.0.0, fourmolu-0.4.0.0,
fourmolu-0.3.0.0, fourmolu-0.2.0.0, fourmolu-0.1.0.0, fourmolu-0.0.6.0 (has
the same characteristics that caused the previous version to fail: excluded by
constraint '==0.7.0.1' from 'hls-fourmolu-plugin')
[__1] fail (backjumping, conflict set: fourmolu, hls-fourmolu-plugin)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: hls-fourmolu-plugin, fourmolu
```
The improvement that I'd like to see would be an additional message, something like:
```
λ ~/Projects/haskell-language-server/plugins/hls-fourmolu-plugin/ mattp/fourmolu-support cabal build
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: hls-fourmolu-plugin-1.0.3.0 (user goal)
[__1] next goal: fourmolu (dependency of hls-fourmolu-plugin)
[__1] rejecting: fourmolu-0.6.0.0 (conflict: hls-fourmolu-plugin =>
fourmolu==0.7.0.1)
[__1] skipping: fourmolu-0.5.0.1, fourmolu-0.5.0.0, fourmolu-0.4.0.0,
fourmolu-0.3.0.0, fourmolu-0.2.0.0, fourmolu-0.1.0.0, fourmolu-0.0.6.0 (has
the same characteristics that caused the previous version to fail: excluded by
constraint '==0.7.0.1' from 'hls-fourmolu-plugin')
[__1] fail (backjumping, conflict set: fourmolu, hls-fourmolu-plugin)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: hls-fourmolu-plugin, fourmolu
Note: You currently have an `index-state` value of XYZ from the configuration file at
/home/matt/Projects/haskell-language-sever/cabal.project
A newer index state may have the version you want
```
The logic for triggering this extra message may look like:
- If a dependency is *newer* than anything in the `index-state`, print it out
The error message could even be extended with a more definitive answer, by checking the newest index-state available.
```
λ ~/Projects/haskell-language-server/plugins/hls-fourmolu-plugin/ mattp/fourmolu-support cabal build
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: hls-fourmolu-plugin-1.0.3.0 (user goal)
[__1] next goal: fourmolu (dependency of hls-fourmolu-plugin)
[__1] rejecting: fourmolu-0.6.0.0 (conflict: hls-fourmolu-plugin =>
fourmolu==0.7.0.1)
[__1] skipping: fourmolu-0.5.0.1, fourmolu-0.5.0.0, fourmolu-0.4.0.0,
fourmolu-0.3.0.0, fourmolu-0.2.0.0, fourmolu-0.1.0.0, fourmolu-0.0.6.0 (has
the same characteristics that caused the previous version to fail: excluded by
constraint '==0.7.0.1' from 'hls-fourmolu-plugin')
[__1] fail (backjumping, conflict set: fourmolu, hls-fourmolu-plugin)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: hls-fourmolu-plugin, fourmolu
Note: You currently have an `index-state` value of XYZ from the configuration file at
/home/matt/Projects/haskell-language-sever/cabal.project
#if the version is present in the newest index state
The newest index-state ABCDEF has the version you want. To
set the index state to this value, replace the value in the config file with this:
index-state: ABCDEF
#else the version is not present in the newest index state
The newest index-state does not have the version. If you've verified
that this version is on Hackage, perhaps try `cabal update`?
#endif
```
Contributor guide
Research direction
Start with `cabal build` dependency resolution failure reporting and the `index-state` configuration described in the issue. Trace how unavailable dependency versions are identified; done means the error explains when the configured index state may exclude a required version and, where applicable, reports the newest index state containing it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- build-system, cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100