lorri icon indicating copy to clipboard operation
lorri copied to clipboard

Garbage collecting deleted projects

Open uosis opened this issue 4 years ago • 5 comments

Feature description

Scenario:

  • check out new project
  • lorri installs 500 dependencies
  • do some work on a project
  • delete the project directory when finished with it
  • 500 dependencies remain forever in the Nix store, useless and inaccessible

The only way to clean up is to delete GC roots from ~/.cache/lorri.

It would seem to make more sense for the GC root symlink to be in the project directory, under .lorri/gcroot or something, rather than in ~/.cache.

Target users

Anyone who works on projects temporarily and then deletes them.

uosis avatar Mar 01 '20 00:03 uosis

Hm, lorri doesn’t really know about projects, all we care about are nix files we evaluate. I’d rather not put files into directories we don’t control if we can help it.

We could have a lorri gc command or similar, which checks whether the producing files still exist and deletes the gc roots if they don’t.

Profpatsch avatar Mar 02 '20 16:03 Profpatsch

Yep lorri gc would work just as well.

Though I don't really see any harm in putting files in "project" directories - in our usage of lorri, if a directory has .envrc with $(lorri direnv) in it, it's effectively controlled by lorri. It would seem entirely reasonable that lorri init would create .lorri subdirectory to store its things.

uosis avatar Mar 03 '20 08:03 uosis

If we store a last-used timestamp, then we can have lorri gc --older-than 30d or whatever, similar to nix-collect-garbage.

michaelpj avatar Mar 16 '20 17:03 michaelpj

For me it would be good enough to just have some command to clear cache.

retrry avatar May 16 '20 08:05 retrry

https://docs.rs/directories/3.0.1/directories/struct.ProjectDirs.html#method.cache_dir by the way, on mac the cache directory is $HOME/Library/Caches/com.github.target.lorri.lorri.lorri.

yihuang avatar Oct 16 '20 02:10 yihuang