haskell / haskell/cabal

Shouldn't cabal error if package depends on itself?

Open
#8,694 0 comments 1 reaction 0 assignees View on GitHub
re: error-message type: enhancement
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

Suppose I have the following cabal file:

```
cabal-version: 1.19
name: text
version: 0.1.0.0
build-type: Simple

executable text
main-is: Main.hs
build-depends: base ==4.14.3.0, text==2.0.1
hs-source-dirs: app
```

By accident I've called my package `text`, despite it not being, yet also *depending on*, the "actual" Haskell `text` package, i.e. the one on Hackage. `cabal build` says

```
% cabal-3.8.1.0 build
Resolving dependencies...
Error: cabal-3.8.1.0: Could not resolve dependencies:
[__0] next goal: text (user goal)
[__0] rejecting: text-2.0.1, text-2.0, text-1.2.5.0,
text-1.2.4.1/installed-1.2.4.1, text-1.2.4.1, text-1.2.4.0, text-1.2.3.2,
text-1.2.3.1, text-1.2.3.0, text-1.2.2.2, text-1.2.2.1, text-1.2.2.0,
text-1.2.1.3, text-1.2.1.2, text-1.2.1.1, text-1.2.1.0, text-1.2.0.6,
text-1.2.0.5, text-1.2.0.4, text-1.2.0.3, text-1.2.0.2, text-1.2.0.0,
text-1.1.1.4, text-1.1.1.3, text-1.1.1.2, text-1.1.1.1, text-1.1.1.0,
text-1.1.0.1, text-1.1.0.0, text-1.0.0.1, text-1.0.0.0, text-0.11.3.1,
text-0.11.3.0, text-0.11.2.3, text-0.11.2.2, text-0.11.2.1, text-0.11.2.0,
text-0.11.1.13, text-0.11.1.12, text-0.11.1.11, text-0.11.1.10, text-0.11.1.9,
text-0.11.1.8, text-0.11.1.7, text-0.11.1.6, text-0.11.1.5, text-0.11.1.3,
text-0.11.1.2, text-0.11.1.1, text-0.11.1.0, text-0.11.0.8, text-0.11.0.7,
text-0.11.0.6, text-0.11.0.5, text-0.11.0.4, text-0.11.0.3, text-0.11.0.2,
text-0.11.0.1, text-0.11.0.0, text-0.10.0.2, text-0.10.0.1, text-0.10.0.0,
text-0.9.1.0, text-0.9.0.1, text-0.9.0.0, text-0.8.1.0, text-0.8.0.0,
text-0.7.2.1, text-0.7.1.0, text-0.7.0.1, text-0.7, text-0.6, text-0.5,
text-0.4, text-0.3, text-0.2 (constraint from user target requires ==0.1.0.0)
[__0] rejecting: text-0.1.0.0 (conflict: text==0.1.0.0, text => text==2.0.1)
[__0] rejecting: text-0.1 (constraint from user target requires ==0.1.0.0)
[__0] fail (backjumping, conflict set: text)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: text
```

That's pretty inscrutable! Shouldn't it say something like "Package text can't depend on itself"? Weirdly, if I delete the `==2.0.1` version in the `text` dependency `cabal` complains with a shorter but also confusing message:

```
Resolving dependencies...
Error:
Dependency on unbuildable package text
In the stanza 'executable text'
In the inplace package 'text-0.1.0.0'
```

And yes, this has led to [real world confusion](https://www.reddit.com/r/haskellquestions/comments/10hxuo3/trying_to_figure_out_cabal_dependency_management).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.