Skip to content

cabal v2-update behaves strangely even with index-state set #7246

@Fuuzetsu

Description

@Fuuzetsu

Describe the bug
I have a cabal.project.freeze file present with index-state value. If I run cabal v2-update, sometimes it uses the right index-state value the first time. If I re-run cabal v2-update without any changes, it will fetch latest Hackage. Re-running cabal v2-update fetches the latest hackage.

If I then specify the index-state value manually to cabal v2-update, on first run it will still show that it's using most recent Hackage snapshot. When I re-run the command, it finally uses the index-state.

To Reproduce
Steps to reproduce the behavior:

$ grep index-state cabal.project.freeze 
index-state: hackage.haskell.org 2021-01-04T03:29:50Z

$ cabal v2-update
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org is up to date at index-state 2021-01-04T03:29:50Z

$ cabal v2-update
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org is up to date at index-state 2021-01-14T01:36:23Z

$ cabal v2-update
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org is up to date at index-state 2021-01-14T01:36:23Z

Here I give up and use the value explicitly.

$ cabal v2-update hackage.haskell.org,2021-01-04T03:29:50Z
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org is up to date at index-state 2021-01-14T01:36:23Z

$ cabal v2-update hackage.haskell.org,2021-01-04T03:29:50Z
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org is up to date at index-state 2021-01-04T03:29:50Z

$ cabal v2-update hackage.haskell.org,2021-01-04T03:29:50Z
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org is up to date at index-state 2021-01-04T03:29:50Z

So now I'm at the index state I actually wanted. If I now run cabal v2-update without arguments, on first run it keeps the original index and on subsequent runs in starts using latest Hackage.

$ cabal v2-update
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org is up to date at index-state 2021-01-04T03:29:50Z

$ cabal v2-update
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org is up to date at index-state 2021-01-14T01:36:23Z

$ cabal v2-update
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org is up to date at index-state 2021-01-14T01:36:23Z

Expected behavior
If I use cabal v2-update in a directory with cabal.project.freeze with index-state set, I expect it to use the value.

Alternatively it should always fetch the latest hackage.

What I do not expect to happen is that running cabal v2-update twice with exactly the same arguments (or none) jumps between two different indices.

System information

$ uname -a
Linux aya 5.4.83 #1-NixOS SMP Fri Dec 11 12:23:33 UTC 2020 x86_64 GNU/Linux

$ ghc --numeric-version
8.8.3

$ cabal --numeric-version
3.4.0.0

To be more precise, I'm using 3.4.0.0-rc4.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions