Hive
Temporary directories are not cleaned up before the CLI exits
GitHub issue · Open
Why is this needed?
We’ve got a report that when using Tuist the disk of their CI machines gets filled up due to Tuist leaving temporary directories in the file-system. Those directories contain different kinds of files, from binary artifacts, to result bundles.
Steps to address the need
We’ll need to understand why that happens, potentially because the process exits before the clean up completes, causing the directories to remain there forever.
Investigate, reproduce, or fix this item in an isolated repository. Each Flight preserves its outcome and agent session.
Start a Flight and preserve its objective, outcome, and session here.
The main reason temporary directories are left behind by Tuist CLI is that many are created with automatic cleanup disabled (removeTreeOnDeinit: false), so they’re not deleted when the process finishes. In several places—like FileHandler.temporaryDirectory(), FileUnarchiver, and the ProjectAutomation.Tuist.graph(at:) helper—cleanup is either manual, only happens on error, or is skipped entirely if the process exits early or crashes. This leads to accumulation of large TemporaryDirectory.* folders, especially in CI environments where many runs happen in parallel or in quick succession. Recent work has improved cleanup for some binary artifacts after extraction, but not for all temp directories or result bundles yet (source, source, source).
To avoid these leaks, it’s best to always enable automatic cleanup when creating temp directories, or ensure they’re deleted on both success and failure paths. Until this is addressed throughout the codebase, periodic manual cleanup of /tmp or similar directories may be needed on CI machines.
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.