Skip to content

[BUG] tmp_pack Files Consuming 180GB on Ubuntu 24.04 LTS #8749

Closed

Description

@vincent-pellerin

Description

[BUG] tmp_pack Files Consuming 180GB on Ubuntu 24.04 LTS

Description

OpenCode is creating massive temporary pack files in ~/.local/share/opencode/snapshot/*/objects/pack/ that are never cleaned up, consuming 180.9 GB of disk space. These tmp_pack_* files appear to accumulate over time without any automatic cleanup mechanism.

Environment

  • OpenCode version: 1.1.21
  • Operating System: Ubuntu 24.04 LTS
  • Desktop Environment: Gnome
  • Hardware: Thinkpad X390 Yoga 2 (2019)
  • Installation method: Official installer (installed to ~/.opencode/bin/)
  • Usage context: Via VSCode integrated terminal

Affected Location

~/.local/share/opencode/snapshot/ed610c2ec990659cd5a93f0917806ddcc867e270/objects/pack/

Files Found

Multiple tmp_pack_* files:

  • tmp_pack_L1OcCi - 34.3 GB
  • tmp_pack_g8Pw3x - 34.3 GB
  • tmp_pack_eBJrkn - 34.3 GB
  • tmp_pack_qruqJT - 34.3 GB
  • tmp_pack_uhAqV2 - 34.3 GB
  • tmp_pack_qdZhkE - 6.2 GB
  • tmp_pack_Eup0BZ - 1.4 GB
  • tmp_pack_j9Ykzw - 1.4 GB
  • tmp_pack_yB0FXj - 332.2 MB

Total: ~180.9 GB

Steps to Reproduce

[Unclear - appears to happen during normal OpenCode usage over time]

  1. Use OpenCode normally over extended period
  2. Files accumulate in snapshot directory
  3. No automatic cleanup occurs

Expected Behavior

Temporary pack files should be automatically cleaned up after use or session end.

Actual Behavior

tmp_pack_* files accumulate indefinitely, consuming massive amounts of disk space (180GB+) without any cleanup mechanism.

Workaround

Manual deletion of temp files:

rm -f ~/.local/share/opencode/snapshot/*/objects/pack/tmp_pack_*

Related Issues

This appears to be related to:

Additional Context

  • Files were write-protected, requiring -f flag to remove
  • This confirms the bug also affects Ubuntu 24.04 LTS (in addition to Ubuntu 22.04)
  • Pattern suggests this is a persistent Ubuntu/Linux issue with OpenCode's temp file management

Impact

  • Critical disk space consumption
  • Can fill entire filesystem
  • Affects system stability
  • No warning or notification to user

Note: This bug report consolidates the issue affecting multiple Ubuntu versions. The pattern is consistent across Ubuntu 22.04 and 24.04 LTS, as well as NixOS.

Plugins

"opencode-anthropic-auth@0.0.8"

OpenCode version

1.1.21

Steps to reproduce

No response

Screenshot and/or share link

Image

Operating System

Ubuntu 24.04.3 LTS

Terminal

VSCode Terminal

Activity

  1. added
    perfIndicates a performance issue or need for optimization
    on Jan 15, 2026
  2. github-actions commented on Jan 15, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if this specific case addresses your unique scenario. However, these issues appear to share the same root cause: OpenCode's snapshot feature and temporary pack file management lack proper cleanup mechanisms on Linux/Unix systems.

  3. tianqiii commented on Jan 16, 2026

    @tianqiii

    It consumes 15+GB on my Ubuntu 25.10. kind of weird. Is there some way to cleanup these files?

    Image
  4. tianqiii commented on Jan 16, 2026

    @tianqiii

    it creates tons of files simultaneously. (202 files)
    Image

  5. vincent-pellerin commented on Jan 22, 2026

    @vincent-pellerin
    Author

    ✅ Root Cause Identified - Complete Analysis Available

    I've completed a deep technical analysis of this bug and found the exact code causing the leak.

    Quick Summary

    Root Cause:

    • Snapshot.track() runs git add . without timeout on every AI interaction (3-5+ times)
    • Long-running git operations fail/timeout → leave tmp_pack files behind
    • .nothrow() silently ignores failures → no cleanup triggered
    • Hourly cleanup runs git gc which doesn't remove tmp_pack files

    My System:

    • ✅ Confirmed: 137GB leaked across 9 tmp_pack files
    • ✅ Found active git process stuck for 10+ minutes at 89% CPU
    • ✅ Cleaned up successfully: 137GB recovered

    Immediate Workaround

    # Kill stuck git processes
    pkill -f "git.*add.*opencode"
    
    # Remove tmp_pack files
    rm -f ~/.local/share/opencode/snapshot/*/objects/pack/tmp_pack_*
    
    # Verify
    du -sh ~/.local/share/opencode/snapshot/*/objects/pack/

    Complete Analysis

    I've created a detailed issue with:

    • ✅ Exact code locations causing the leak
    • ✅ Code-level fix recommendations (timeout, cleanup, error handling)
    • ✅ Testing plan
    • ✅ Configuration options

    See: #10034 - [ROOT CAUSE ANALYSIS] tmp_pack Leak - Complete Code Analysis & Fix Recommendations

    Recommended Fixes (for maintainers)

    Priority 1 (CRITICAL):

    1. Add 30-second timeout to git operations
    2. Enhance cleanup to explicitly remove tmp_pack files

    Priority 2 (HIGH):
    3. Add error handling with exit code checking
    4. Call cleanup on failed git operations

    Priority 3 (MEDIUM):
    5. Reduce snapshot frequency with throttling

    All details, code snippets, and evidence in #10034.


    Confirmed affected: Ubuntu 22.04, 24.04, 25.10, NixOS
    Related issues: #5617, #6845, #6523, #8577 - all same root cause

  6. thdxr commented on Mar 25, 2026

    @thdxr
    Member

    This should be partially addressed by commit 0a80ef4 which adds a 2MB file size limit for snapshotting. Large files are now excluded from git snapshots, which should reduce the tmp_pack accumulation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingperfIndicates a performance issue or need for optimization

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions