Skip to content

cli: global config only loads when cwd is $HOME, not subfolders #36485

Closed

Description

@diegoquiroz

Summary

The global config file (~/.config/opencode/opencode.jsonc) is only loaded when running opencode2 from $HOME. When running from any subfolder (e.g. $HOME/dev, $HOME/dev/project), the global config is ignored and no MCP servers, instructions, or other settings are applied.

Environment

  • opencode version: 0.0.0-next-15355 (next channel)
  • OS: Darwin 25.5.0, arm64 (macOS, Apple Silicon)
  • Terminal: xterm-256color with truecolor support
  • Shell: /bin/zsh
  • Install/channel: mise-managed, opencode2 binary via Node, next channel
  • Active plugins: None configured

Reproduction

  1. Place a valid config at ~/.config/opencode/opencode.jsonc with MCP servers defined (e.g. chrome-devtools, github_grep).
  2. Open a terminal in $HOME and run opencode2.
  3. Run /status — confirms 2 MCP servers connected.
  4. Close opencode, cd ~/Developer, run opencode2 again.
  5. Run /status — shows "No MCP Servers".

Expected Behavior

The global config at ~/.config/opencode/opencode.jsonc should be loaded regardless of the current working directory, so MCP servers and other settings work in any subfolder.

Actual Behavior

Only $HOME triggers global config loading. All subfolders get an empty config state.

Additional Context

  • No opencode.json or opencode.jsonc exists in ~/Developer or its parents between $HOME and ~/Developer (confirmed via fd).

opencode2 in $HOME

Image

opencode2 in $HOME/Developer

Image

Output of fd opencode showing there is no config file overwriting the global one

Image

Activity

  1. diegoquiroz commented on Jul 12, 2026

    @diegoquiroz
    Author

    Probably the bug was introduced in one of today's releases (July 11th) because it was working earlier

  2. opencode-agent commented on Jul 12, 2026

    @opencode-agent
    Contributor

    Could you share the output of the following from both $HOME and $HOME/Developer? Please redact anything sensitive.

    printf 'XDG_CONFIG_HOME=%q\nOPENCODE_CONFIG_DIR=%q\n' "$XDG_CONFIG_HOME" "$OPENCODE_CONFIG_DIR"
    opencode2 debug paths

    Also, does the following load the global config correctly from $HOME/Developer?

    env -u XDG_CONFIG_HOME -u OPENCODE_CONFIG_DIR opencode2

    This will tell us whether a relative config-directory override is being resolved against the current working directory.

  3. diegoquiroz commented on Jul 12, 2026

    @diegoquiroz
    Author

    Could you share the output of the following from both $HOME and $HOME/Developer? Please redact anything sensitive.

    Image

    Also, does the following load the global config correctly from $HOME/Developer?

    No, still opens without loading the config. I tried to also set manually the value of $OPENCODE_CONFIG_DIR and had no effect.

  4. diegoquiroz commented on Jul 13, 2026

    @diegoquiroz
    Author

    Fixed on #36577

  5. diegoquiroz commented on Jul 14, 2026

    @diegoquiroz
    Author

    Nevermind, it only works on non-git subfolders and I believe the commit above had nothing to do with it.
    Won't reopen because #36539 already explains the current behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions