haskell / haskell/cabal

Non-matching structured hashes with head.hackage

Open
#9,829 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

After successfully building with head.hackage, I'm seeing build failures because the index is locked. I don't yet have a reproduction but have seen this yesterday and today.

```
$ cabal build all --enable-tests --enable-benchmarks --dry-run --minimize-conflict-set
Warning: this is a debug build of cabal-install with assertions enabled.
Warning: Parsing the index cache failed (Data.Binary.Get.runGet at position
16: Non-matching structured hashes: f46da61e7afa58a5e8fd1d2b6fb79899;
expected: d81bdd513f41b5d7ee4cd28455adadbe). Trying to regenerate the index
cache...
Warning: Parsing the index cache failed (Data.Binary.Get.runGet at position
16: Non-matching structured hashes: f46da61e7afa58a5e8fd1d2b6fb79899;
expected: d81bdd513f41b5d7ee4cd28455adadbe). Trying to regenerate the index
cache...
~/.cabal/packages/head.hackage.ghc.haskell.org/01-index.tar: withFile: resource busy (file is locked)
```

The workaround I'm using is to delete `~/.cabal/packages/head.hackage.ghc.haskell.org` followed up by `cabal update`. Could this be a problem if we start using head.hackage in CI?

## Set up of `head.hackage`

```
$ curl https://ghc.gitlab.haskell.org/head.hackage/cabal.project >> cabal.project.local
$ cabal update
```

I followed the above [head.hackage instructions](https://ghc.gitlab.haskell.org/head.hackage/) with master. The default `cabal.project` builds but not at first;

```
$ cabal --version
cabal-install version 3.11.0.0
compiled using version 3.11.0.0 of the Cabal library

$ git rev-parse HEAD
46e822152c9b3f38044870115d7a198b3a509d66

$ cabal build all --enable-tests --enable-benchmarks --dry-run
Warning: this is a debug build of cabal-install with assertions enabled.
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] next goal: Cabal (user goal)
[__0] rejecting: Cabal-3.11.0.0
(cabal.project.local requires ==2.4.1.0 || ==3.0.2.0 || ==3.2.1.0)
[__0] rejecting: Cabal-3.10.2.1, Cabal-3.10.2.0/installed-fd40, Cabal-3.10.2.0, Cabal-3.10.1.0, Cabal-3.8.1.0, Cabal-3.6.3.0, Cabal-3.6.2.0, Cabal-3.6.1.0, Cabal-3.6.0.0, Cabal-3.4.1.0, Cabal-3.4.0.0, Cabal-3.2.1.0, Cabal-3.2.0.0, Cabal-3.0.2.0, Cabal-3.0.1.0, Cabal-3.0.0.0, Cabal-2.4.1.0, Cabal-2.4.0.1, Cabal-2.4.0.0, Cabal-2.2.0.1, Cabal-2.2.0.0, Cabal-2.0.1.1, Cabal-2.0.1.0, Cabal-2.0.0.2, Cabal-1.24.2.0, Cabal-1.24.0.0, Cabal-1.22.8.0, Cabal-1.22.7.0, Cabal-1.22.6.0, Cabal-1.22.5.0, Cabal-1.22.4.0, Cabal-1.22.3.0, Cabal-1.22.2.0, Cabal-1.22.1.1, Cabal-1.22.1.0, Cabal-1.22.0.0, Cabal-1.20.0.4, Cabal-1.20.0.3, Cabal-1.20.0.2, Cabal-1.20.0.1, Cabal-1.20.0.0, Cabal-1.18.1.7, Cabal-1.18.1.6, Cabal-1.18.1.5, Cabal-1.18.1.4, Cabal-1.18.1.3, Cabal-1.18.1.2, Cabal-1.18.1.1, Cabal-1.18.1, Cabal-1.18.0, Cabal-1.16.0.3, Cabal-1.16.0.2, Cabal-1.16.0.1, Cabal-1.16.0, Cabal-1.14.0, Cabal-1.12.0, Cabal-1.10.2.0, Cabal-1.10.1.0, Cabal-1.10.0.0, Cabal-1.8.0.6, Cabal-1.8.0.4, Cabal-1.8.0.2, Cabal-1.6.0.3, Cabal-1.6.0.2, Cabal-1.6.0.1, Cabal-1.4.0.2, Cabal-1.4.0.1, Cabal-1.4.0.0, Cabal-1.2.4.0, Cabal-1.2.3.0, Cabal-1.2.2.0, Cabal-1.2.1, Cabal-1.1.6, Cabal-1.24.1.0 (constraint from user target requires ==3.11.0.0)
[__0] fail (backjumping, conflict set: Cabal)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: Cabal
```

I can fix this by commenting out the constraint conflict on `Cabal` in `cabal.project.local`;

```diff
$ git diff
diff --git a/cabal.project.local b/cabal.project.local
index 576224433..9b6fb23cb 100644
--- a/cabal.project.local
+++ b/cabal.project.local
@@ -31,7 +31,7 @@ constraints:
template-haskell installed

constraints:
- Cabal ==2.4.1.0 || ==3.0.2.0 || ==3.2.1.0,
+ -- Cabal ==2.4.1.0 || ==3.0.2.0 || ==3.2.1.0,
Cabal-syntax ==3.8.1.0,
FPretty ==1.1,
JuicyPixels ==3.3.8,
```

Try again and there's another conflict for `Cabal-syntax` that I can fix the same way;

```
$ cabal build all --enable-tests --enable-benchmarks --dry-run
Warning: this is a debug build of cabal-install with assertions enabled.
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] next goal: Cabal-syntax (user goal)
[__0] rejecting: Cabal-syntax-3.11.0.0
(constraint from cabal.project.local requires ==3.8.1.0)
[__0] rejecting: Cabal-syntax-3.10.2.0/installed-8eb4, Cabal-syntax-3.10.2.0, Cabal-syntax-3.10.1.0, Cabal-syntax-3.8.1.0, Cabal-syntax-3.6.0.0 (constraint from user target requires ==3.11.0.0)
[__0] fail (backjumping, conflict set: Cabal-syntax)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: Cabal-syntax
```

```diff
$ git diff
diff --git a/cabal.project.local b/cabal.project.local
index 576224433..c92471375 100644
--- a/cabal.project.local
+++ b/cabal.project.local
@@ -31,8 +31,8 @@ constraints:
template-haskell installed

constraints:
- Cabal ==2.4.1.0 || ==3.0.2.0 || ==3.2.1.0,
- Cabal-syntax ==3.8.1.0,
+ -- Cabal ==2.4.1.0 || ==3.0.2.0 || ==3.2.1.0,
+ -- Cabal-syntax ==3.8.1.0,
FPretty ==1.1,
JuicyPixels ==3.3.8,
ansi-pretty ==0.1.2.2,
```

Now `cabal build ...` works.

_Originally posted by @philderbeast in https://github.com/haskell/cabal/issues/9808#issuecomment-2009648095_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the head.hackage setup from the linked instructions, then run the shown `cabal build ... --dry-run --minimize-conflict-set` command and inspect the affected `~/.cabal/packages/head.hackage.ghc.haskell.org` index cache. The report currently has no reproduction; done should include a reliable reproduction and verified behavior for the locked index and structured-hash failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.