Yarn: Autoclean deprecated cache folders (OS X, linux, etc)

Created on 26 Jun 2017  路  6Comments  路  Source: yarnpkg/yarn

This is more of an enquiry, as I noticed yesterday when going through my disk usage that Yarn was taking up a fair bit of space for it's cache. This is not a problem in itself, but what I found odd is that there were seemingly two cache locations, so I was wondering if Yarn is using both, or if one of them is a legacy location that hasn't been cleaned up.

I found cache files both in my user directory under ~/.yarn-cache as well as in~/Library/Caches/Yarn.

I cleaned up both and from what it seems only the Library one has been recreated. Is this the one in use now? If so it might be a good idea to have yarn auto-clean the old location if there's still files present there.

cat-feature good first issue help wanted triaged

All 6 comments

I think ~/.yarn-cache is from an older version.
I guess it would not hurt if cache clean would clean all known cache locations.

@bestander can you give me some context on this issue? I'm new to the community, so finding it a bit hard in finding the code for this.

@reznord, this feature has been evolving for quite a while.

The first basic approach was to put caches inside HOME folder, like ~/.yarn-cache, then we realized that ~/.yarn/cache would be better, then linux people said they want to have it in their standard Cache folder, then OSX people said that ~/Library/Cacges/Yarn would be the right places for caches, then there is also a custom folder for Windows.
On top of this, sometimes you need to care about sudo permissions to the cache folder and fallback to home if Yarn does not have access.
At that point I stopped caring and just make sure we balance between being a good citizen in the OS and don't make the cache folder resolution too hard.

Ah the life of a software developer... 馃槅

@bestander
I was looking into this issue and wanted to know if my thought regarding the fix is right. Would it involve making sure that we don't only take the first suitable folder while deleting the cache but also every cache folder that yarn has write permissions to? Right now it only deletes the first suitable folder that it comes across in https://github.com/yarnpkg/yarn/blob/95a3aa9538ea6b7a67950b34a3782fbf64dfe4fe/src/config.js#L301

@sreeramjayan, it would make sense to clean legacy cache folders.
Feel free to send a PR.

Was this page helpful?
0 / 5 - 0 ratings