Skip to content

opencode.json/config.json search path #3407

Closed

Description

@arlt

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

Activity

  1. added
    bugSomething isn't working
    on Oct 24, 2025
  2. github-actions commented on Oct 24, 2025

    @github-actions
    Contributor

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

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

  3. rekram1-node commented on Oct 24, 2025

    @rekram1-node
    Collaborator

    @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

  4. arlt commented on Oct 24, 2025

    @arlt
    Author

    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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions