haskell / haskell/cabal

`cabal install --lib` errors should point to the package environment that cause the error

Open
#7,820 5 comments 0 reactions 0 assignees View on GitHub
attention: pr-welcome blocked: needs reproducer cabal-install: cmd/install re: error-message re: install --lib
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

E.g., trying (GHC 9.2.1, cabal `master`):
```
$ cabal install --lib microlens
Resolving dependencies...
Error: cabal: Could not resolve dependencies:
[__0] trying: directory-1.3.7.0 (user goal)
[__1] next goal: ghc (user goal)
[__1] rejecting: ghc-9.2.1/installed-9.2.1 (conflict: directory==1.3.7.0, ghc
=> directory==1.3.6.2/installed-1.3.6.2)
[__1] trying: ghc-9.2.1
[__2] unknown package: unbuildable (dependency of ghc)
[__2] fail (backjumping, conflict set: ghc, unbuildable)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: directory, ghc, unbuildable
```
This is surprising, as `microlens` does not have any dependencies except `base`.

With `ghc-pkg` there was no problem, but after some longer digging I remembered https://ghc.gitlab.haskell.org/ghc/doc/users_guide/packages.html#package-environments and found `.ghc/x86_64-darwin-9.2.1/environments/default`:
```
clear-package-db
global-package-db
package-db /Users/abel/.cabal/store/ghc-9.2.1/package.db
package-id ghc-9.2.1
...
package-id template-haskell-2.18.0.0
package-id drctry-1.3.7.0-75757ae7
package-id text-1.2.5.0
package-id prttyprntr-1.7.1-58b4e5f6
package-id xtr-1.7.10-74cdb974
```
So with knowledge of #7209 I can identify `drctry` (dorctry? --- no, `directory`!!) as source of conflict. (I still wonder how it ended up here if it conflicts with `ghc-9.2.1`??)

I still think that
```
[__0] trying: directory-1.3.7.0 (user goal)
```
is inaccurate when I invoked `cabal` on `microlens`.

The output should rather reveal the correct source of the `directory-1.3.7.0` goal.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported `cabal install --lib microlens` failure with GHC 9.2.1 and inspect the referenced `.ghc/x86_64-darwin-9.2.1/environments/default` package environment. Trace how the dependency solver reports the `directory-1.3.7.0` goal; done means the error identifies the package environment source rather than presenting it as a user goal.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.