juliaup icon indicating copy to clipboard operation
juliaup copied to clipboard

`juliaup gc` should prune linked versions that no longer exist

Open staticfloat opened this issue 1 year ago • 1 comments

If I have a juliaup configuration with lots of linked julia versions it can be unwieldy to clean them up. Uf those versions of Julia have been deleted from my harddrive, I think it makes sense that juliaup gc should remove the links too (or at least provide an option to do so, such as --prune-linked).

staticfloat avatar Jun 23 '24 18:06 staticfloat

This is another issue that makes for a good first issue for someone who wants to contribute. Essentially all we need is another loop in https://github.com/JuliaLang/juliaup/blob/7c7e9c0cac86f3b35e190cfd248421a72ac83676/src/operations.rs#L531 over the content of config_data.installed_channels that matches on JuliaupConfigChannel::LinkedChannel and then checks if that version still exists and if not deletes the channel.

Two other points:

  • I think we should have it an option as --prune-linked because the gc function is called at various points "just in case" and I think it would be weird and surprising for users if at random points their channels disappeared. So that means the implementation also needs to add a command line flag.
  • Actually detecting whether a linked version still exists is maybe a little bit more tricky than I thought... Linked channels do not point to a file location, they are stored as a command with arguments. So I think maybe we need to spawn the command with an additional -v parameter and if that fails to launch we assume the version is gone?

davidanthoff avatar Jun 25 '24 09:06 davidanthoff