haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.62k stars 697 forks source link

cabal update is stuck on old index-state #9796

Open tomjaguarpaw opened 8 months ago

tomjaguarpaw commented 8 months ago

Describe the bug

If I run cabal update I get the index-state from 2024-02-21T10:56:14Z which is several days out of date.

To Reproduce

% cabal update
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org is up to date.
The index-state is set to 2024-02-21T10:56:14Z.

Expected behavior

A more recent index-state

System information

% cabal --version && ghc --version
cabal-install version 3.10.2.1
compiled using version 3.10.2.1 of the Cabal library 
The Glorious Glasgow Haskell Compilation System, version 9.4.8

Additional context

In theory this could be a hackage-server issue, but I deduced it to be a cabal issue because of the following. If I run with -v I get

% cabal update -v                 
Project settings changed, reconfiguring...
Downloading the latest package list from hackage.haskell.org
Selected mirror http://hackage.haskell.org/
Downloading timestamp
Running: /usr/bin/curl 'http://hackage.haskell.org/timestamp.json' --output /tmp/transportAdapterGet369534-1 --location --write-out '%{http_code}' --user-agent 'cabal-install/3.10.2.1 (linux; x86_64)' --silent --show-error --dump-header /tmp/curl-headers369534-2.txt
Waiting to acquire cache lock on
/home/tom/.cabal/packages/hackage.haskell.org/hackage-security-lock
Acquired cache lock on
/home/tom/.cabal/packages/hackage.haskell.org/hackage-security-lock
Released cache lock on
/home/tom/.cabal/packages/hackage.haskell.org/hackage-security-lock
Package list of hackage.haskell.org is up to date.
The index-state is set to 2024-02-21T10:56:14Z.

and then if I run

% /usr/bin/curl 'http://hackage.haskell.org/timestamp.json'
{"signatures":[{"keyid":"aa315286e6ad281ad61182235533c41e806e5a787e0b6d1e7eef3f09d137d2e9","method":"ed25519","sig":"EL6N65OAI4YqyFZFy1B5R2THWyBKsIXvAWV7459VNFay+rffS86gId8xDXDS87cUaVtcMdJgstJrqNk50lxxCw=="}],"signed":{"_type":"Timestamp","expires":"2024-03-14T05:41:27Z","meta":{"<repo>/snapshot.json":{"hashes":{"md5":"495be164eb823f873b0f6c42e43ade54","sha256":"31d1d2cf5d557fd8ab7af6c220d04e58bcd667a111ae80fcf7f0a499c1e0db41"},"length":970}},"version":94437}}

so at least the http://hackage.haskell.org/timestamp.json has the correct timestamp. Then if I move my .cabal directory away and try afresh I get the correct index-state

% mv .cabal .cabal.away
% cabal update
Config file path source is default config file.
Config file not found: /home/tom/.config/cabal/config
Writing default configuration to /home/tom/.config/cabal/config
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org has been updated.
The index-state is set to 2024-03-11T05:40:28Z.

After having done that, if I move .cabal.away back to .cabal the issue no longer appears:

% cabal update
Warning: Both /home/tom/.cabal and /home/tom/.config/cabal/config exist -
ignoring the former.
It is advisable to remove one of them. In that case, we will use the remaining
one by default (unless '$CABAL_DIR' is explicitly set).
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org is up to date.
The index-state is set to 2024-03-11T05:40:28Z.

But then if I

% rm /home/tom/.config/cabal/config  

then the issue comes back

% cabal update
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org is up to date.
The index-state is set to 2024-02-21T10:56:14Z.

I have absolutely no idea what's going on here, why ~/.config/cabal/config is relevant, and why ~/.config/cabal/config and ~/.cabal shouldn't both exist. (Maybe it means ~/.cabal/config rather than ~/.cabal).

andreasabel commented 8 months ago

Not by any chance an index-state setting in your project file?, like:

index-state: hackage.haskell.org 2023-04-03T14:24:39Z

Also, what is in your cabal config file? E.g. I have

repository hackage.haskell.org
  url: http://hackage.haskell.org/
  secure: True
remote-repo-cache: /Users/abel/.cabal/packages

Dug into the .json files in your repo cache? (Sorry, I am just throwing random things at you, but maybe this random feed nevertheless helps you on your bug chase...)

Another random thought: It is not by any chance an XDG issue that cabal looks for the repo cache in two different places?