OPENCODE_CONFIG_DIR does not read custom config file. #2910

Closed
opened 2026-02-16 17:37:45 -05:00 by yindo · 2 comments
Owner

Originally created by @nitg16 on GitHub (Nov 17, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

Config file opencode.json stored in OPENCODE_CONFIG_DIR does not work when doing this:

export OPENCODE_CONFIG_DIR=~/data/opencode

Config file opencode.json stored in OPENCODE_CONFIG_DIR works only when exporting both:

export OPENCODE_CONFIG_DIR=~/data/opencode
export OPENCODE_CONFIG=~/data/opencode/opencode.json

Ideally OPENCODE_CONFIG_DIR env var should be enough to load custom config from a custom config directory.

OpenCode version

v1.0.68

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

Ubuntu Linux

Terminal

No response

Originally created by @nitg16 on GitHub (Nov 17, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description Config file opencode.json stored in `OPENCODE_CONFIG_DIR` does not work when doing this: ```bash export OPENCODE_CONFIG_DIR=~/data/opencode ``` Config file opencode.json stored in `OPENCODE_CONFIG_DIR` works only when exporting both: ```bash export OPENCODE_CONFIG_DIR=~/data/opencode export OPENCODE_CONFIG=~/data/opencode/opencode.json ``` Ideally `OPENCODE_CONFIG_DIR` env var should be enough to load custom config from a custom config directory. ### OpenCode version v1.0.68 ### Steps to reproduce _No response_ ### Screenshot and/or share link _No response_ ### Operating System Ubuntu Linux ### Terminal _No response_
yindo added the bug label 2026-02-16 17:37:45 -05:00
yindo closed this issue 2026-02-16 17:37:45 -05:00
Author
Owner

@rekram1-node commented on GitHub (Nov 17, 2025):

/oc please fix this, read config.ts update this:
if (Flag.OPENCODE_CONFIG_DIR) {
directories.push(Flag.OPENCODE_CONFIG_DIR)
log.debug("loading config from OPENCODE_CONFIG_DIR", { path: Flag.OPENCODE_CONFIG_DIR })
}

const promises: Promise<void>[] = []
for (const dir of directories) {
  await assertValid(dir)

  if (dir.endsWith(".opencode")) {
    for (const file of ["opencode.jsonc", "opencode.json"]) {
      log.debug(`loading config from ${path.join(dir, file)}`)
      result = mergeDeep(result, await loadFile(path.join(dir, file)))
      // to satisy the type checker
      result.agent ??= {}
      result.mode ??= {}
      result.plugin ??= []
    }
  }

To also read opencode.json/opencode.jsonc if the dir is the flag dir

@rekram1-node commented on GitHub (Nov 17, 2025): /oc please fix this, read config.ts update this: if (Flag.OPENCODE_CONFIG_DIR) { directories.push(Flag.OPENCODE_CONFIG_DIR) log.debug("loading config from OPENCODE_CONFIG_DIR", { path: Flag.OPENCODE_CONFIG_DIR }) } const promises: Promise<void>[] = [] for (const dir of directories) { await assertValid(dir) if (dir.endsWith(".opencode")) { for (const file of ["opencode.jsonc", "opencode.json"]) { log.debug(`loading config from ${path.join(dir, file)}`) result = mergeDeep(result, await loadFile(path.join(dir, file))) // to satisy the type checker result.agent ??= {} result.mode ??= {} result.plugin ??= [] } } To also read opencode.json/opencode.jsonc if the dir is the flag dir
Author
Owner

@opencode-agent[bot] commented on GitHub (Nov 17, 2025):

Created PR #4400

New%20session%20-%202025-11-17T05%3A46%3A38.944Z
opencode session  |  github run

@opencode-agent[bot] commented on GitHub (Nov 17, 2025): Created PR #4400 <a href="https://opencode.ai/s/4cg2iZKz"><img width="200" alt="New%20session%20-%202025-11-17T05%3A46%3A38.944Z" src="https://social-cards.sst.dev/opencode-share/TmV3IHNlc3Npb24gLSAyMDI1LTExLTE3VDA1OjQ2OjM4Ljk0NFo=.png?model=opencode/glm-4.6&version=1.0.68&id=4cg2iZKz" /></a> [opencode session](https://opencode.ai/s/4cg2iZKz)&nbsp;&nbsp;|&nbsp;&nbsp;[github run](/sst/opencode/actions/runs/19419738479)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2910