[FEATURE]: Support OPENCODE_CACHE_DIR and OPENCODE_LOG_DIR for full isolation #6528

Open
opened 2026-02-16 18:04:30 -05:00 by yindo · 1 comment
Owner

Originally created by @Robitx on GitHub (Jan 16, 2026).

Originally assigned to: @thdxr on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Following up on issue #4526 and PR #8963. While moving the data directory is a great start, OpenCode still writes logs, state, and transient caches to fixed global system paths. This makes it difficult to run truly isolated instances.

Proposed Solution Add support for:

  • OPENCODE_CACHE_DIR: For all transient state (indexes, caches, npm plugins).
  • OPENCODE_LOG_DIR: For session logs.
  • OPENCODE_STATE_DIR: For UI state (model selection, prompt history, stashed prompts, frecency data).

Why?

  • Environment Hygiene: Prevents metadata leakage between different project contexts.
  • Portability: Allows a user to wrap an entire environment (config, data, cache, logs, state) into a single path for easier backup or migration.
  • Multi-instance Support: Running multiple OpenCode sessions with different identities/configs without path collisions in ~/.cache, /.local/share, or /.local/state.

EDIT:

I've extended PR #8963 to cover this also. The PR now includes all four environment variables:

  • OPENCODE_DATA_DIR (original request from #4526)
  • OPENCODE_CACHE_DIR (added to address this issue)
  • OPENCODE_LOG_DIR (added to address this issue)
  • OPENCODE_STATE_DIR (added to address this issue)

With all five environment variables (OPENCODE_CONFIG_DIR, OPENCODE_DATA_DIR, OPENCODE_CACHE_DIR, OPENCODE_LOG_DIR, OPENCODE_STATE_DIR), OpenCode achieves full portable mode with zero reliance on default XDG directories.

Originally created by @Robitx on GitHub (Jan 16, 2026). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request Following up on issue #4526 and PR #8963. While moving the data directory is a great start, OpenCode still writes logs, state, and transient caches to fixed global system paths. This makes it difficult to run truly isolated instances. Proposed Solution Add support for: - OPENCODE_CACHE_DIR: For all transient state (indexes, caches, npm plugins). - OPENCODE_LOG_DIR: For session logs. - OPENCODE_STATE_DIR: For UI state (model selection, prompt history, stashed prompts, frecency data). Why? - Environment Hygiene: Prevents metadata leakage between different project contexts. - Portability: Allows a user to wrap an entire environment (config, data, cache, logs, state) into a single path for easier backup or migration. - Multi-instance Support: Running multiple OpenCode sessions with different identities/configs without path collisions in ~/.cache, /.local/share, or /.local/state. EDIT: I've extended PR #8963 to cover this also. The PR now includes all four environment variables: - OPENCODE_DATA_DIR (original request from #4526) - OPENCODE_CACHE_DIR (added to address this issue) - OPENCODE_LOG_DIR (added to address this issue) - OPENCODE_STATE_DIR (added to address this issue) With all five environment variables (OPENCODE_CONFIG_DIR, OPENCODE_DATA_DIR, OPENCODE_CACHE_DIR, OPENCODE_LOG_DIR, OPENCODE_STATE_DIR), OpenCode achieves full portable mode with zero reliance on default XDG directories.
yindo added the discussion label 2026-02-16 18:04:30 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 16, 2026):

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

  • #4526: [FEATURE]: Full portable mode. - Requests OPENCODE_DATA_DIR environment variable to enable full portability by relocating data directory
  • #4170: Reorganize and document dirs for config, agents, auth credentials, sessions - Documents the scattered directory structure across ~/.config, ~/.local/share, ~/.local/state, and ~/.cache and requests reorganization

These issues are closely related to your feature request for OPENCODE_CACHE_DIR and OPENCODE_LOG_DIR. The combined solutions would provide the full isolation and portability you're describing.

Feel free to ignore if you believe this request addresses something more specific.

@github-actions[bot] commented on GitHub (Jan 16, 2026): This issue might be a duplicate of existing issues. Please check: - #4526: [FEATURE]: Full portable mode. - Requests OPENCODE_DATA_DIR environment variable to enable full portability by relocating data directory - #4170: Reorganize and document dirs for config, agents, auth credentials, sessions - Documents the scattered directory structure across ~/.config, ~/.local/share, ~/.local/state, and ~/.cache and requests reorganization These issues are closely related to your feature request for OPENCODE_CACHE_DIR and OPENCODE_LOG_DIR. The combined solutions would provide the full isolation and portability you're describing. Feel free to ignore if you believe this request addresses something more specific.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6528