File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ export namespace Flag {
44 export const OPENCODE_CONFIG = process . env [ "OPENCODE_CONFIG" ]
55 export const OPENCODE_CONFIG_DIR = process . env [ "OPENCODE_CONFIG_DIR" ]
66 export const OPENCODE_CONFIG_CONTENT = process . env [ "OPENCODE_CONFIG_CONTENT" ]
7+ export const OPENCODE_DATA_DIR = process . env [ "OPENCODE_DATA_DIR" ]
78 export const OPENCODE_DISABLE_AUTOUPDATE = truthy ( "OPENCODE_DISABLE_AUTOUPDATE" )
89 export const OPENCODE_DISABLE_PRUNE = truthy ( "OPENCODE_DISABLE_PRUNE" )
910 export const OPENCODE_DISABLE_TERMINAL_TITLE = truthy ( "OPENCODE_DISABLE_TERMINAL_TITLE" )
Original file line number Diff line number Diff line change @@ -2,10 +2,11 @@ import fs from "fs/promises"
22import { xdgData , xdgCache , xdgConfig , xdgState } from "xdg-basedir"
33import path from "path"
44import os from "os"
5+ import { Flag } from "../flag/flag"
56
67const app = "opencode"
78
8- const data = path . join ( xdgData ! , app )
9+ const data = Flag . OPENCODE_DATA_DIR || path . join ( xdgData ! , app )
910const cache = path . join ( xdgCache ! , app )
1011const config = path . join ( xdgConfig ! , app )
1112const state = path . join ( xdgState ! , app )
Original file line number Diff line number Diff line change @@ -558,6 +558,7 @@ OpenCode can be configured using environment variables.
558558| ` OPENCODE_CONFIG ` | string | Path to config file |
559559| ` OPENCODE_CONFIG_DIR ` | string | Path to config directory |
560560| ` OPENCODE_CONFIG_CONTENT ` | string | Inline json config content |
561+ | ` OPENCODE_DATA_DIR ` | string | Path to data directory |
561562| ` OPENCODE_DISABLE_AUTOUPDATE ` | boolean | Disable automatic update checks |
562563| ` OPENCODE_DISABLE_PRUNE ` | boolean | Disable pruning of old data |
563564| ` OPENCODE_DISABLE_TERMINAL_TITLE ` | boolean | Disable automatic terminal title updates |
Original file line number Diff line number Diff line change @@ -138,6 +138,20 @@ opencode run "Hello world"
138138
139139The custom directory is loaded after the global config and ` .opencode ` directories, so it ** can override** their settings.
140140
141+ ### Custom data directory
142+
143+ Specify a custom data directory using the ` OPENCODE_DATA_DIR `
144+ environment variable. This controls where OpenCode stores runtime data
145+ like authentication tokens, logs, cached files, and LSP binaries.
146+
147+ ``` bash
148+ export OPENCODE_DATA_DIR=/path/to/my/data-directory
149+ opencode run " Hello world"
150+ ```
151+
152+ By default, OpenCode stores data in ` ~/.local/share/opencode ` on Linux/macOS
153+ or ` %LOCALAPPDATA%\opencode ` on Windows.
154+
141155---
142156
143157## Schema
You can’t perform that action at this time.
0 commit comments