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

tmp directory filled by yarn (and not cleaned) #6685

Closed
nicolas-lecab opened this issue Nov 15, 2018 · 31 comments · May be fixed by #7207
Closed

tmp directory filled by yarn (and not cleaned) #6685

nicolas-lecab opened this issue Nov 15, 2018 · 31 comments · May be fixed by #7207
Assignees
Labels

Comments

@nicolas-lecab
Copy link

Do you want to request a feature or report a bug?
bug

What is the current behavior?
Each "yarn run" will create a directory under "/tmp" directory which looks like

/tmp/yarn--1542302743598-0.6454897498245407

If the current behavior is a bug, please provide the steps to reproduce.
Let's say we have a script in package.json as follow:

    "scripts": {
        "dummy": "echo 'dummy'"
    }

If we play this dummy script and we check number of directories before and after in /tmp:

$> ls -dla /tmp/yarn* | grep $USER | wc -l
0

$> yarn run dummy
yarn run v1.12.3
$ echo 'dummy'
dummy
Done in 0.12s.

$> ls -dla /tmp/yarn* | grep $USER | wc -l
1

Running the dummy script will increment the result each time.
FYI:

  • yarn is installed globally
  • bug seems to appear somewhere between v1.10.0 and v1.11.0 (I can't reproduce with 1.10.0)

What is the expected behavior?
Tmp directory should not be filled indefinitely: it should reuse the already created temporary files (if tmp is really needed) or it should have some kind of cleaning mechanism to avoid overwhelmingly the tmp directory.

Please mention your node.js, yarn and operating system version.
node: v8.9.4
nvm: 0.33.2
yarn: 1.12.3
os: Debian 3.16.51-3

@ghost ghost assigned arcanis Nov 15, 2018
@ghost ghost added the triaged label Nov 15, 2018
@ellioseven
Copy link

I am getting the same results on 1.12.3. Not really sure why this is happening?

I noticed each tmp entry has a shell script relating to node and yarn. I have tried running yarn run with different flags such as --link-folder, --global-folder and --cache-folder but I can't seem to prevent the directories from being created.

@arcanis
Copy link
Member

arcanis commented Nov 28, 2018

Yarn creates a temporary directory each time a script is executed, in order to setup "fake" Node and "fake" Yarn binaries that point towards the exact same Yarn/Node than those currently being executed (to prevent the case where the global Node is different from the one used to run Yarn itself).

The problem is that they never get removed at the moment:
https://github.com/yarnpkg/yarn/blob/master/src/util/execute-lifecycle-script.js#L31-L48

@tomq42
Copy link

tomq42 commented Feb 7, 2019

Yep, also see this.

@BookOfGreg
Copy link

BookOfGreg commented Mar 11, 2019

My /tmp is 24gb almost all of which is the Yarn files described above.

me@me:~$ sudo du -hs /tmp
24G     /tmp
me@me:~$ uptime
 15:58:04 up 52 days,  5:30,  1 user,  load average: 0.97, 0.87, 0.50

Was this a regression? I don't remember my CI agents being filled by this in the past.

@lexaurin
Copy link

lexaurin commented Jun 6, 2019

The same problem with yarn 1.15.2

@ZLima12
Copy link

ZLima12 commented Jun 6, 2019

Still happening for me with yarn 1.16.0.

@xmontero
Copy link

xmontero commented Jun 17, 2019

In the meantime.... Is it safe to manually remove all of them? Or the removal could break anything?

@JLarky
Copy link

JLarky commented Jun 17, 2019 via email

@nicolas-lecab
Copy link
Author

@xmontero We removed files older than 1 day on our dev server.
Never had issue since then.
10 4 * * * find /tmp/ -name "yarn*" -type d -mtime +1 -exec rm -rf {} \; > /dev/null

@arcanis
Copy link
Member

arcanis commented Jun 18, 2019

There is no risk removing those files when Yarn isn't running. Even when running, it should be relatively safe as they're usually only used when the program boots.

Fwiw this problem will be fixed from the v2 onward; the artifacts will be properly discarded right after the commands return.

@lexaurin
Copy link

lexaurin commented Jun 18, 2019 via email

@dvdknaap
Copy link

Still getting this at the current version

@ClementNerma
Copy link

It's still not fixed at this time, even on latest 1.21.1 version :/

@djsiddz
Copy link

djsiddz commented May 7, 2020

Is this issue persistent with yarn v2? If anyone has tried this, please let me know. I am giving it a shot today with v2 on one of our apps to check this in the mean time.

@snowl
Copy link

snowl commented Jun 9, 2020

@djsiddz Did v2 fix it for you?

@dvdknaap
Copy link

De issue still exists in the latest version

sh yarn -version
1.22.4

sh ls -alF

drwxr-xr-x 2 username username 4096 Jun 9 11:57 yarn--1591696641892-0.05204308679429248/
drwxr-xr-x 2 username username 4096 Jun 10 14:55 yarn--1591793724850-0.4196722332063454/
drwxr-xr-x 2 username username 4096 Jun 10 15:15 yarn--1591794953501-0.3040314059514666/
drwxr-xr-x 2 username username 4096 Jun 10 15:26 yarn--1591795571216-0.8222359319740244/
drwxr-xr-x 2 username username 4096 Jun 11 09:33 yarn--1591860782625-0.15962323877699136/
drwxr-xr-x 2 username username 4096 Jun 11 09:36 yarn--1591860987612-0.0746955607161679/
drwxr-xr-x 2 username username 4096 Jun 11 11:03 yarn--1591866191467-0.6557044172705777/
drwxr-xr-x 2 username username 4096 Jun 11 11:04 yarn--1591866263355-0.7429486092878892/
drwxr-xr-x 2 username username 4096 Jun 11 11:07 yarn--1591866427043-0.3962468811805635/
drwxr-xr-x 2 username username 4096 Jun 11 12:50 yarn--1591872605318-0.8161204330414475/
drwxr-xr-x 2 username username 4096 Jun 11 12:50 yarn--1591872605322-0.48513192538032124/
drwxr-xr-x 2 username username 4096 Jun 11 12:50 yarn--1591872622244-0.4583333405082548/
drwxr-xr-x 2 username username 4096 Jun 11 13:59 yarn--1591876762200-0.05283671445181093/
drwxr-xr-x 2 username username 4096 Jun 11 14:09 yarn--1591877355444-0.7000002370403433/

@ClementNerma
Copy link

ClementNerma commented Jun 11, 2020

I can confirm this still happens on the very same version (1.22.4).
Platform: Debian 10 on WSL - Windows 10 x64 ver 19041 (2004).

@ezeqd
Copy link

ezeqd commented Oct 1, 2020

Any update on this? we still have several problems with hard disk and "no left space" on Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-38-generic x86_64) with
yarn -v
1.13.0

@mohux
Copy link

mohux commented Oct 28, 2020

still not fixed? :/ my server is filled with tmp yarn files

@namnm
Copy link

namnm commented Dec 10, 2020

Yarn was so good, until this. Funny thing is this issue has been reported since like more than 2 years ago, and no collaborator care about fixing this, even there is an existing PR #7207 to review.

@NobodysNightmare
Copy link

@arcanis wrote:

Fwiw this problem will be fixed from the v2 onward; the artifacts will be properly discarded right after the commands return.

Just for clarification (even if it will hurt), I guess this means version 1.x will not receive a fix, but 2.x has the issue fixed? In this case the issue could IMO be closed, but it would be nice to have clarity on that.

Comparing to the description of this repository itself:

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry

@arcanis
Copy link
Member

arcanis commented Mar 3, 2021

Just for clarification (even if it will hurt), I guess this means version 1.x will not receive a fix, but 2.x has the issue fixed? In this case the issue could IMO be closed, but it would be nice to have clarity on that.

Indeed. Note that the migration should be fairly painless if you follow the migration guide, since it explains how to stay on the typical node_modules install strategy even with 2+.

@danielmarschall

This comment has been minimized.

@vanowm
Copy link

vanowm commented Dec 14, 2021

Is there a "manual" script we could run that would clean up after yarn finished?

@ClementNerma
Copy link

Is there a "manual" script we could run that would clean up after yarn finished?

On Unix-based systems (Linux & co):

rm /tmp/yarn--*

@vanowm
Copy link

vanowm commented Apr 16, 2022

Is there a "manual" script we could run that would clean up after yarn finished?

on Windows OS this can be used:

for /d /r "%temp%" %i in (yarn--*) do @rmdir /s /q "%i"

@kunwoo-choi
Copy link

kunwoo-choi commented Aug 9, 2022

I clear tmp directory in every hour by crontab, but sometimes server dies because of this(even at dawn!!)
I cannot figure out why my server access to the tmp file at 11:28(not an exact 11:00 or 12:00).

But if I do not clear this regulary, our server instance is filled by yarn! I'm in a dilemma.

스크린샷 2022-08-09 오전 11 28 08

.

@minured
Copy link

minured commented Jan 25, 2023

version 1.22.19 still exsits. the problem reported in 2018, and still not fixed in 2023 :)

@jcruz97

This comment was marked as abuse.

@jcruz97
Copy link

jcruz97 commented Apr 6, 2023

Instead of marking comment as "abusive" you can fix this up?

@arcanis
Copy link
Member

arcanis commented Apr 6, 2023

@jcruz97 No, because it's already fixed in modern releases - upgrade and you won't have this problem anymore. As for your post, it was quite unprofessional and wasn't really worth visibility.

@arcanis arcanis closed this as completed Apr 6, 2023
@yarnpkg yarnpkg locked as resolved and limited conversation to collaborators Apr 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.