opencode.json/config.json search path #2261

Closed
opened 2026-02-16 17:34:52 -05:00 by yindo · 3 comments
Owner

Originally created by @arlt on GitHub (Oct 24, 2025).

Description

I tried to configure disabled_providers. One can read about

  • ~/.config/opencode/config.json
  • ~/.config/opencode/opencode.json

but strace shows that opencode looks at the following places:

  1. ~/.config/opencode/config.json
  2. ~/.config/opencode/opencode.json
  3. ~/.config/opencode/opencode.jsonc
  4. $PWD/opencode.jsonc # folder where i started opencode
  5. ~/opencode.jsonc
  6. /home/opencode.jsonc
  7. /opencode.jsonc
  8. $PWD/opencode.json # folder where i started opencode
  9. ~/opencode.json
  10. /home/opencode.json
  11. /opencode.json

/opencode.json wins, so if i centrally provide /opencode.json, i override the user specific setting - this is fine.
But /opencode.json?! Why not /etc/...?

I wonder if the paths are intentional. From my point of view, it might make more sense that way:

  1. ~/.config/opencode/config.json or $HOME/.config/opencode/opencode.json
  2. $PWD/opencode.json
  3. /etc/opencode.json or /etc/opencode/opencode.json or /etc/opencode/config.json

To clear up the confusion surrounding opencode.json vs. config.json, I would probably opt for opencode.json (which can be found in the documentation e.g. https://opencode.ai/docs/rules/#custom-instructions) - so maybe:

  1. $HOME/.config/opencode/opencode.json
  2. $PWD/opencode.json # by this I mean the project folder in which opencode works.
  3. /etc/opencode.json or /etc/opencode/opencode.json

The latter ones shoud always override the former ones (merge).

I used a bug report since /opencode.json is not the correct place for a central configuration in my opinion.

OpenCode version

0.15.16

Steps to reproduce

  1. strace -fo log opencode # exit after start
  2. grep -oE '/.*(config|opencode).json[^"]*' log

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Originally created by @arlt on GitHub (Oct 24, 2025). ### Description I tried to configure `disabled_providers`. One can read about - `~/.config/opencode/config.json` - `~/.config/opencode/opencode.json` but strace shows that opencode looks at the following places: 1. `~/.config/opencode/config.json` 1. `~/.config/opencode/opencode.json` 1. `~/.config/opencode/opencode.jsonc` 1. `$PWD/opencode.jsonc` # folder where i started opencode 1. `~/opencode.jsonc` 1. `/home/opencode.jsonc` 1. `/opencode.jsonc` 1. `$PWD/opencode.json` # folder where i started opencode 1. `~/opencode.json` 1. `/home/opencode.json` 1. `/opencode.json` `/opencode.json` wins, so if i centrally provide `/opencode.json`, i override the user specific setting - this is fine. But `/opencode.json`?! Why not /etc/...? I wonder if the paths are intentional. From my point of view, it might make more sense that way: 1. `~/.config/opencode/config.json` or `$HOME/.config/opencode/opencode.json` 1. `$PWD/opencode.json` 1. `/etc/opencode.json` or `/etc/opencode/opencode.json` or `/etc/opencode/config.json` To clear up the confusion surrounding `opencode.json` vs. `config.json`, I would probably opt for `opencode.json` (which can be found in the documentation e.g. https://opencode.ai/docs/rules/#custom-instructions) - so maybe: 1. `$HOME/.config/opencode/opencode.json` 1. `$PWD/opencode.json` # by this I mean the project folder in which opencode works. 1. `/etc/opencode.json` or `/etc/opencode/opencode.json` The latter ones shoud always override the former ones (merge). I used a bug report since `/opencode.json` is not the correct place for a central configuration in my opinion. ### OpenCode version 0.15.16 ### Steps to reproduce 1. `strace -fo log opencode` # exit after start 2. `grep -oE '/.*(config|opencode).json[^"]*' log` ### Screenshot and/or share link _No response_ ### Operating System _No response_ ### Terminal _No response_
yindo added the bug label 2026-02-16 17:34:52 -05:00
yindo closed this issue 2026-02-16 17:34:52 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 24, 2025):

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

  • #3395: What's the proper way to pass current working directory to the global opencode.json config? (discusses configuration file paths and usage)
  • #3191: Opencode adds stuff to global config folder (discusses configuration directory structure and file placement)
  • #3289: Glob patterns with / expansion don't work in instructions configuration (related to configuration file path handling)

Feel free to ignore if none of these address your specific case about the extensive search path and /opencode.json placement.

@github-actions[bot] commented on GitHub (Oct 24, 2025): This issue might be a duplicate of existing issues. Please check: - #3395: What's the proper way to pass current working directory to the global opencode.json config? (discusses configuration file paths and usage) - #3191: Opencode adds stuff to global config folder (discusses configuration directory structure and file placement) - #3289: Glob patterns with ~/~ expansion don't work in instructions configuration (related to configuration file path handling) Feel free to ignore if none of these address your specific case about the extensive search path and /opencode.json placement.
Author
Owner

@rekram1-node commented on GitHub (Oct 24, 2025):

@arlt the config.json is legacy so we search it for backwards compatibility also we search 3 diffferent ones here because they are all supported:

~/.config/opencode/config.json
~/.config/opencode/opencode.json
~/.config/opencode/opencode.jsonc

This is once again just for legacy support but we try to have most people use opencode.json or opencode.jsonc

This code is what causes those other file paths tho:

    for (const file of ["opencode.jsonc", "opencode.json"]) {
      const found = await Filesystem.findUp(file, Instance.directory, Instance.worktree)
      for (const resolved of found.toReversed()) {
        result = mergeDeep(result, await loadFile(resolved))
      }
    }

it just searches up the filesystem to check if you have any other opencode configs that it should be loading in, if you are in a git repo it should stop at the root of the repo, but if you are outside of a git repo it will look up to the global "/"

This isn't a bug this is intentional behavior

@rekram1-node commented on GitHub (Oct 24, 2025): @arlt the config.json is legacy so we search it for backwards compatibility also we search 3 diffferent ones here because they are all supported: ``` ~/.config/opencode/config.json ~/.config/opencode/opencode.json ~/.config/opencode/opencode.jsonc ``` This is once again just for legacy support but we try to have most people use `opencode.json` or `opencode.jsonc` This code is what causes those other file paths tho: ``` for (const file of ["opencode.jsonc", "opencode.json"]) { const found = await Filesystem.findUp(file, Instance.directory, Instance.worktree) for (const resolved of found.toReversed()) { result = mergeDeep(result, await loadFile(resolved)) } } ``` it just searches up the filesystem to check if you have any other opencode configs that it should be loading in, if you are in a git repo it should stop at the root of the repo, but if you are outside of a git repo it will look up to the global "/" This isn't a bug this is intentional behavior
Author
Owner

@arlt commented on GitHub (Oct 24, 2025):

it just searches up the filesystem to check if you have any other opencode configs that it should be loading in, if you are in a git repo it should stop at the root of the repo, but if you are outside of a git repo it will look up to the global "/"

This isn't a bug this is intentional behavior

Ah - thanks for clarifying that.

@arlt commented on GitHub (Oct 24, 2025): > it just searches up the filesystem to check if you have any other opencode configs that it should be loading in, if you are in a git repo it should stop at the root of the repo, but if you are outside of a git repo it will look up to the global "/" > > This isn't a bug this is intentional behavior Ah - thanks for clarifying that.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2261