Weird solver behaviour: doesn't consider installed version first
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
**Describe the bug**
`cabal-install` is eager to reinstall `filepath`, while there doesn't seem any reason to.
**To Reproduce**
```
$ cabal build
```
**Expected behavior**
A clear and concise description of what you expected to happen.
**System information**
`cabal-install-3.10.2.1`, `ghc-9.8.2`
**Additional context**
When building e.g. `haskell-ci` without any constraints
We see
```haskell
[__0] trying: cabal-install-parsers-0.6.2 (user goal)
[__1] trying: base-4.19.1.0/installed-c38a (dependency of cabal-install-parsers)
[__2] trying: rts-1.0.2/installed-1.0.2 (dependency of base)
[__3] trying: ghc-prim-0.11.0/installed-9ff8 (dependency of base)
[__4] trying: ghc-bignum-1.3/installed-5d39 (dependency of base)
[__5] trying: transformers-0.6.1.0/installed-bca4 (dependency of cabal-install-parsers)
[__6] trying: time-1.12.2/installed-d509 (dependency of cabal-install-parsers)
[__7] trying: text-2.1.1/installed-cc4c (dependency of cabal-install-parsers)
[__8] trying: template-haskell-2.21.0.0/installed-f842 (dependency of text)
[__9] trying: ghc-boot-th-9.8.2/installed-cec8 (dependency of template-haskell)
[_10] trying: array-0.5.6.0/installed-b08f (dependency of text)
[_11] trying: tar-0.6.2.0 (dependency of cabal-install-parsers)
[_12] trying: tar:!bench
[_13] trying: tar:!test
[_14] trying: os-string-2.0.2.1 (dependency of tar)
[_15] trying: os-string:!bench
[_16] trying: os-string:!test
[_17] trying: exceptions-0.10.7/installed-93ec (dependency of os-string)
[_18] trying: stm-2.5.2.1/installed-73cd (dependency of exceptions)
[_19] trying: mtl-2.3.1/installed-0d33 (dependency of exceptions)
[_20] trying: pretty-1.1.3.6/installed-c96a (dependency of cabal-install-parsers)
[_21] trying: parsec-3.1.17.0/installed-d3a0 (dependency of cabal-install-parsers)
[_22] trying: network-uri-2.6.4.2 (dependency of cabal-install-parsers)
[_23] trying: network-uri:!bench
[_24] trying: network-uri:!test
[_25] trying: th-compat-0.1.5 (dependency of network-uri)
[_26] trying: th-compat:!test
[_27] trying: lukko-0.1.1.3 (dependency of cabal-install-parsers)
[_28] trying: lukko:!test
[_29] next goal: filepath (dependency of cabal-install-parsers)
[_29] rejecting: filepath-1.5.2.0 (conflict: cabal-install-parsers => filepath^>=1.4.1.1)
[_29] trying: filepath-1.4.300.2
[_30] trying: filepath:!bench
[_31] trying: filepath:!test
[_32] trying: filepath:-cpphs
```
With `-c filepath` installed:
```
[__0] trying: cabal-install-parsers-0.6.2 (user goal)
[__1] trying: base-4.19.1.0/installed-c38a (dependency of cabal-install-parsers)
[__2] trying: rts-1.0.2/installed-1.0.2 (dependency of base)
[__3] trying: ghc-prim-0.11.0/installed-9ff8 (dependency of base)
[__4] trying: ghc-bignum-1.3/installed-5d39 (dependency of base)
[__5] trying: transformers-0.6.1.0/installed-bca4 (dependency of cabal-install-parsers)
[__6] trying: time-1.12.2/installed-d509 (dependency of cabal-install-parsers)
[__7] trying: text-2.1.1/installed-cc4c (dependency of cabal-install-parsers)
[__8] trying: template-haskell-2.21.0.0/installed-f842 (dependency of text)
[__9] trying: ghc-boot-th-9.8.2/installed-cec8 (dependency of template-haskell)
[_10] trying: array-0.5.6.0/installed-b08f (dependency of text)
[_11] trying: tar-0.6.2.0 (dependency of cabal-install-parsers)
[_12] trying: tar:!bench
[_13] trying: tar:!test
[_14] trying: os-string-2.0.2.1 (dependency of tar)
[_15] trying: os-string:!bench
[_16] trying: os-string:!test
[_17] trying: exceptions-0.10.7/installed-93ec (dependency of os-string)
[_18] trying: stm-2.5.2.1/installed-73cd (dependency of exceptions)
[_19] trying: mtl-2.3.1/installed-0d33 (dependency of exceptions)
[_20] trying: pretty-1.1.3.6/installed-c96a (dependency of cabal-install-parsers)
[_21] trying: parsec-3.1.17.0/installed-d3a0 (dependency of cabal-install-parsers)
[_22] trying: network-uri-2.6.4.2 (dependency of cabal-install-parsers)
[_23] trying: network-uri:!bench
[_24] trying: network-uri:!test
[_25] trying: th-compat-0.1.5 (dependency of network-uri)
[_26] trying: th-compat:!test
[_27] trying: lukko-0.1.1.3 (dependency of cabal-install-parsers)
[_28] trying: lukko:!test
[_29] next goal: filepath (dependency of cabal-install-parsers)
[_29] rejecting: filepath-1.5.2.0, filepath-1.4.300.2, filepath-1.4.300.1, filepath-1.4.101.0, filepath-1.4.2.2, filepath-1.4.2.1, filepath-1.4.2, filepath-1.4.1.2, filepath-1.4.1.1, filepath-1.4.1.0, filepath-1.4.0.0, filepath-1.3.0.2, filepath-1.3.0.1, filepath-1.3.0.0, filepath-1.2.0.1, filepath-1.2.0.0, filepath-1.1.0.4, filepath-1.1.0.3, filepath-1.1.0.2, filepath-1.1.0.1, filepath-1.1.0.0, filepath-1.0 (constraint from command line flag requires installed instance)
[_29] trying: filepath-1.4.200.1/installed-6350
```
In either case, solver doesn't consider installed filepath first. I'd expect that there's some bound somewhere pushing either way, but there doesnt' seem to as the build plan difference is
```diff
-directory-1.3.8.1 lib
+directory-1.3.8.4 lib
-filepath-1.4.200.1 lib
+filepath-1.4.300.2 lib
-process-1.6.18.0 lib
+process-1.6.19.0 lib
-unix-2.8.4.0 lib
+unix-2.8.5.1 lib
```
Why solver doesn't consider installed `filepath` first?
Contributor guide
Research direction
Start by reproducing the issue with `cabal build` using the reported `cabal-install-3.10.2.1` and `ghc-9.8.2` versions, then compare solver traces with and without `-c filepath`. Trace why the installed filepath version is not considered first; done means the selection behavior is explained and the unnecessary reinstall is corrected or the expected behavior is clarified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100