Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yarn cache caused impossible total size #13

Closed
phoenecke opened this issue Aug 15, 2019 · 10 comments
Closed

Yarn cache caused impossible total size #13

phoenecke opened this issue Aug 15, 2019 · 10 comments
Assignees
Labels
bug Something isn't working properly done Finished working on the issue good first issue Good for newcomers

Comments

@phoenecke
Copy link

On MacOS, I ran it in my home directory and it said 600 GB. My laptop only has a 512 GB SSD.
There were many node_modules folders in my Yarn cache.

After running yarn cache clean, npkill said ~2 GB.

@zaldih
Copy link
Member

zaldih commented Aug 15, 2019

omg it seems that npkill found a quantum link!

Thank you for opening this issue. We will investigate the origin of this calculation failure (I suspect that it may be a problem of rounding figures as there are so many directories).

  • Do you know how much space the cache really occupied?
  • Those ~ 2GB that shows npkill correspond to the actual size or is it also wrong?

@phoenecke
Copy link
Author

The 2 GB seems correct and it finds the same amount each time I run it.

Another thing I forgot to mention is that I ran it twice before doing yarn cache clean and it gave different results. The first time, it was about 570 gb and the second time it was over 600.

Unfortunately I did not check the real size of the Yarn cache before cleaning it.

@d4rky-pl
Copy link

d4rky-pl commented Aug 16, 2019

Before yarn cache clean:

 releasable space: 377791.00 mb

After yarn cache clean:

releasable space: 4207.00 mb

The size of yarn cache:

5.6G	Yarn

@zaldih I believe this is indeed because of the rounding issue. Almost all of the folders were reported as having 1 mb. An excerpt:

  /Users/matyas/Library/Caches/Yarn/v4/npm-array-find-index-1.0.2-df010aa1287e164bbda6f9723b0a96a1ec4187a1/node_modules      1 mb
  /Users/matyas/Library/Caches/Yarn/v4/npm-pretty-error-2.1.1-5f4f87c8f91e5ae3f3ba87ab4cf5e03b1a17f1a3/node_modules          1 mb
  /Users/matyas/Library/Caches/Yarn/v4/npm-query-string-6.8.1-62c54a7ef37d01b538c8fd56f95740c81d438a26/node_modules          1 mb
  /Users/matyas/Library/Caches/Yarn/v4/npm-filesize-3.6.1-090bb3ee01b6f801a8a8be99d31710b3422bb317/node_modules              1 mb
  /Users/m...ary/Caches/Yarn/v4/npm-character-entities-legacy-1.1.3-3c729991d9293da0ede6dddcaf1f2ce1009ee8b4/node_modules    1 mb
  /Users/m...brary/Caches/Yarn/v4/npm-eslint-plugin-flowtype-2.50.3-61379d6dce1d010370acd6681740fd913d68175f/node_modules    1 mb
  /Users/matyas/Library/Caches/Yarn/v4/npm-diff-sequences-24.3.0-0f20e8a1df1abddaf4d9c226680952e64118b975/node_modules       1 mb

@zaldih
Copy link
Member

zaldih commented Aug 16, 2019

Yess! Is a problem fo rounding.
I have been able to verify that in windows this does not happen because its service has more precision.

Captura

However, linux service uses the du command with some parameter that rounds at least 1mb, although a directory only occupies 0.01mb

const du = spawn('du', ['-sm', path, '--max-depth', '0']);

A possible solution would be to investigate how to get the size in bytes with that command, and convert them to mb in the same way as windows service does.

This seems like a simple bug for anyone who would like to contribute to the repo for the first time. 😃

Does anyone take it?

@zaldih zaldih added bug Something isn't working properly good first issue Good for newcomers labels Aug 16, 2019
@NyaGarcia
Copy link
Member

I'll fix it :D

@NyaGarcia NyaGarcia self-assigned this Aug 16, 2019
@zaldih
Copy link
Member

zaldih commented Aug 17, 2019

The problem should now be fixed in #18 🎉
In the next update this fix will be included

@NyaGarcia NyaGarcia added the done Finished working on the issue label Aug 18, 2019
@NyaGarcia
Copy link
Member

Issue should be fixed from version 4.0.0 onwards

@maxdevjs
Copy link

maxdevjs commented Jul 24, 2020

Got this today :)

Yarn cache was around 300MB, npkill returned around 260GB 🤔

@NyaGarcia
Copy link
Member

@maxdevjs We realized that by merging #74, the bug reappeared. I'm working on a solution on this branch. However, my solution would only fix the bug on Linux, not MacOS.

This is because the du parameter that fixes the bug (--apparent-size) has no equivalent in MacOS (as far as I know). I'm researching for a way to fix it in MacOS, but so far I haven't found anything. If anyone has any ideas, I'd love to try them out :)

@maxdevjs
Copy link

@NyaGarcia thank you for the reply.

I quickly checked #74 and the suggested branch, I guess the solution you are working on is

const du = spawn('du', ['-s', '--apparent-size', '-k', path]);

right?

That said, my bad! Just to be clear, I tried it on Linux.

This changes the focus of my question: currently happens on both Linux and MacOS?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working properly done Finished working on the issue good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants