Fix regression in local+noindex repository handling
Template B: This PR does not modify behaviour or interface
This fixes #9891, introduced in #8944, where the index cache is checked even for local+noindex repositories.
Include the following checklist in your PR:
- [ ] Patches conform to the coding conventions.
- [ ] Is this a PR that fixes CI? If so, it will need to be backported to older cabal release branches (ask maintainers for directions).
Rebasing on latest master for a CI fix.
Sorry for the noise, testing a bot to track review requests
I am actually not sure why I had marked this as a draft. Maybe because it's missing a test :thinking:
Should that be backported for release 3.12.2.0? The PR that introduced the problem is old, so it's surely on the 3.12 branch.
This doesn't solve the regression, at least on Windows.
The cabal file
➜ cat cabal.project
packages: .
repository local
url: file+noindex://C:/Users/Javier/code/aa/repo
3.10.2.1
➜ ls repo
➜ cabal build
Resolving dependencies...
Build profile: -w ghc-9.6.5 -O1
In order, the following will be built (use -v for more details):
- aa-0.1.0.0 (lib) (cannot read state cache)
Configuring library for aa-0.1.0.0..
Preprocessing library for aa-0.1.0.0..
Building library for aa-0.1.0.0..
[1 of 1] Compiling MyLib ( src\MyLib.hs, C:\Users\Javier\code\aa\dist-newstyle\build\x86_64-windows\ghc-9.6.5\aa-0.1.0.0\build\MyLib.o ) [Flags changed]
➜ ls repo
noindex.cache
surprisingly enough, it prints the paths in verbose mode as missing the C:/ drive letter, but it still creates the file 🧩 :
➜ cabal build -v3 | grep -v environment
...
Reading available packages of local...
Using most recent state (could not read timestamp file)
Updating index cache file /Users/Javier/code/aa/repo\noindex.cache ...
Entries in file+noindex repository local
creating \Users\Javier\code\aa\repo
Index cache updated
index-state(local) =
...
With this branch's cabal
➜ ls repo
➜ $CABAL build
Warning: this is a debug build of cabal-install with assertions enabled.
Warning: Error during construction of local+noindex local repository index:
/Users/Javier/code/aa/repo\noindex.cache: openBinaryFile: does not exist (No
such file or directory)
Resolving dependencies...
Build profile: -w ghc-9.6.5 -O1
In order, the following will be built (use -v for more details):
- aa-0.1.0.0 (lib) (cannot read state cache)
Warning: this is a debug build of cabal-install with assertions enabled.
Configuring library for aa-0.1.0.0...
Warning: this is a debug build of cabal-install with assertions enabled.
Preprocessing library for aa-0.1.0.0...
Building library for aa-0.1.0.0...
[1 of 1] Compiling MyLib ( src\MyLib.hs, dist-newstyle\build\x86_64-windows\ghc-9.6.5\aa-0.1.0.0\build\MyLib.o ) [Flags changed]
Warning: this is a debug build of cabal-install with assertions enabled.
➜ ls repo
This one says:
➜ $CABAL build -v3 | grep -v environment
...
Warning: Error during construction of local+noindex local repository index:
/Users/Javier/code/aa/repo\noindex.cache: openBinaryFile: does not exist (No
such file or directory)
index-state(hackage.haskell.org) = 2024-06-20T22:19:34Z
Reading available packages of local...
index-state(local) = Unknown or invalid timestamp
...
Thanks @jasagredo. (if only I had written a test :joy:)
@andreabedini any energy to get back to this? It may be good to manage it before 3.14 release since people start noticing: https://github.com/haskell/cabal/issues/9891#issuecomment-2284299345
@andreabedini: do you think it's ready for another round of reviews? Any help needed?
@andreabedini: ping, ping! :)
Superseded by #10730