haskell / cabal

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

Per-Version Index Cache in ~/.cabal directory #7502

Open gbaz opened 3 years ago

gbaz commented 3 years ago

Switching between cabal install versions can occur either when developing cabal, or when using nix-shells that bring different versions into scope, among other reasons.

Each time you switch versions, you get Warning: Parsing the index cache failed and it needs to regenerate the index cache.

This can be tedious and time consuming.

I suggest that cabal store its index cache per-cabal-version rather than always in the same spot, thus helping to more frequently avoid this issue.

Mikolaj commented 3 years ago

No counterindication, as far as I can see.

ptkato commented 3 years ago

That would be an welcome change, specially when developing for cabal, since there are usually multiple cabals involved in the whole compile/run thingy.

phadej commented 3 years ago

This was discussed and it is not trivial. The cabal update command wouldn't update the cache files of other cabal-install versions. That is probably not a problem for Hackage index as it's append only (so the old index cache will just not see new stuff), but e.g. with head.hackage index (which is competely overwritten) very weird things will happen.

Please outline how you would prevent cache corruption.

gbaz commented 3 years ago

Good point about cabal update! Does it do a full rewrite of the index cache file or is it an in-place update?

gbaz commented 3 years ago

The obvious thing to do is to just have update remove all versions of the index cache, and let them be generated as necessary on demand. I think this would be pretty seamless...

andreasabel commented 3 years ago

I think this issue is important to fix, because having several versions of cabal-install around is the advice when one still relies on sandboxes.