volta icon indicating copy to clipboard operation
volta copied to clipboard

Implement command to remove cached downloads

Open mikrostew opened this issue 5 years ago • 11 comments

NOTE: this issue predates this project's rename to Volta.

This command is basically the inverse of notion fetch <node/npm/yarn/package> - it should remove the cached downloads for the specified tool from the inventory directory.

There was a discussion on discord, and several options for the syntax of this command were proposed:

  • notion delete
  • notion prune
  • notion cleanup
  • notion clear-cache

Whatever is chosen, there should be a corresponding flag for notion uninstall to also remove the cached files.

mikrostew avatar Mar 29 '19 21:03 mikrostew

I think this needs to be re-prioritized. I've had volta on my machine for almost a year now. And have nearly 10GB of storage dedicated to the inventory/ and image/node/ folders. Spanning almost every version of node since 10.

Am I safe to just delete old images? Will it break anything?

maraisr avatar May 15 '20 10:05 maraisr

It is safe to delete old images, because if you’re in a project where you need one of them, Volta will just re-download it for you.

(This size usage is the big reason I’d like the feature as well. My personal laptop is woefully undersized storage-wise, so I end up just throwing away all my images every so often to keep clutter down.)

chriskrycho avatar May 15 '20 11:05 chriskrycho

would love this! while it is super easy just to rm -rf the node version in the tools/image/node directory this would still be a great quality of life update

es50678 avatar Apr 23 '21 21:04 es50678

It'd be great if this command would also run automatically, e.g., each month when some other Volta un/install command is executed so that you wouldn't have to worry about the manual chore of such a cleanup

eugenesvk avatar May 21 '22 12:05 eugenesvk

I've made a small utility to remove unused Node versions from Volta: https://pypi.org/project/vnu/

hxii avatar Jun 08 '22 16:06 hxii

just to rm -rf the node version in the tools/image/node directory

but why is this not yet among Volta commands ...

SeryiBaran avatar Jul 22 '23 15:07 SeryiBaran

If we can remove cached Node versions by hand or with a Python script, it can't see a reason why Volta can't provide it internally.

hdodov avatar Nov 11 '23 09:11 hdodov

https://gist.github.com/chintan9/0375fba3477374616c007fa2866227a0

use this script in nodejs 16 or higher required

chintan9 avatar Nov 28 '23 03:11 chintan9

A couple quick notes here, in case anyone wants to design and implement a volta purge-cache or something:

  1. We wouldn't want to do it on a schedule (though you could schedule it yourself once the command exists using cron or launchd or similar): imagine you have a project you'd like to work on while on a nice long airplane flight, and Volta cleaned up your cache for you automatically, and you got on your plane and tried to start working… and now have to try to re-download Node and a package manager over airplane wi-fi (good luck!), and that's assuming you even have wi-fi on the flight. 😬 Net, this should always be an on-demand operation, because while it is always safe to do in the general case, you do actually have to re-download it. There are lots of other scenarios when you don't want that!

  2. If someone wants to implement that, the design should account for default/user-level tool installations. It's possible this already “just works” when blowing away the downloads, but it is important to make sure that continues to be true, i.e. that a tool installed to the user toolchain (not just a project toolchain) also gets re-downloaded appropriately if it has been removed. It may be better, in that case (and since we have the data relatively locally, and don't have to crawl the user's whole FS to find it) to leave alone versions which are installed for user-toolchain tool installations.

  3. This might not be obvious, but: we cannot (at least in the current design) provide a particularly smart implementation here where we only remove unused items—because to do that we would need to check the user's entire file system for any package.json specifying a given version. We can clear the cache, and we might be able to account for user tools, but we cannot handle the fully-general “smart” version here—more or less by design!

In the meantime, the scripts folks have written and shared do work reasonably well, and are also straightforward to implement as a scheduled job if/as people prefer!

chriskrycho avatar Nov 28 '23 19:11 chriskrycho

I'd like to remove unused installation as it get's piling up. Seems this is a must have feature

iamchathu avatar Jan 08 '24 19:01 iamchathu

I had a problem with the wrong architecture of node due to volta. volta uninstall node fails and node is the only cache that actually matters.

I fixed it by deleting ~/.volta/tools/image and rerunning the yarn install command in the respective project.

I don't know what ~/.volta/cache is for, tried deleting it and didn't seem to affect anything.

I think volta uninstall node should just delete the downloaded image instead of doing nothing as volta seems to automatically reinstall it.

There's no point adding new complicated commands cuz it's all arbitrary in the end anyway.

ProLoser avatar Mar 11 '24 23:03 ProLoser