Fix XDG base directory support for config and log paths#350
Merged
Tarquinen merged 2 commits intoOpencode-DCP:devfrom Feb 5, 2026
Merged
Fix XDG base directory support for config and log paths#350Tarquinen merged 2 commits intoOpencode-DCP:devfrom
Tarquinen merged 2 commits intoOpencode-DCP:devfrom
Conversation
Config loader now checks XDG_CONFIG_HOME before falling back to ~/.config/opencode. Logger now uses XDG_DATA_HOME (defaulting to ~/.local/share) for log storage, which is where runtime data belongs per the XDG Base Directory Specification. No behavior change for users with default (unset) XDG paths.
Collaborator
|
I think you missed one spot in lib/state/persistence.ts, can you add that as well to the PR please? Thank you for your help! |
STORAGE_DIR in persistence.ts also hardcoded ~/.local/share instead of checking XDG_DATA_HOME. Same pattern as the logger fix.
Contributor
Author
|
Agent found and fixed the persistence.ts. Thanks for the direction. |
Collaborator
|
Looks good, thank you! The dev branch is cooking a pretty huge update, I need a day or two more before it can be released so this will be in @latest probably friday. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #349
Summary
Config loader and logger hardcode
homedir()/.config/opencodeinstead of respectingXDG_CONFIG_HOMEandXDG_DATA_HOMEenvironment variables. This causes DCP to fail to find its config file and fail to write debug logs for any user running with custom XDG base directories.What Changed
lib/config.tsBefore:
const GLOBAL_CONFIG_DIR = join(homedir(), ".config", "opencode")
After:
const GLOBAL_CONFIG_DIR = process.env.XDG_CONFIG_HOME
? join(process.env.XDG_CONFIG_HOME, "opencode")
: join(homedir(), ".config", "opencode")
lib/logger.ts
Before:
const opencodeConfigDir = join(homedir(), ".config", "opencode")
this.logDir = join(opencodeConfigDir, "logs", "dcp")
After:
const dataHome =
process.env.XDG_DATA_HOME || join(homedir(), ".local", "share")
this.logDir = join(dataHome, "opencode", "logs", "dcp")
Note: The logger also moves from the config directory (XDG_CONFIG_HOME) to the data directory (XDG_DATA_HOME), which is where logs belong per the XDG spec. Log files are runtime data, not configuration.
Behavior
No breaking changes for users with default paths.
Testing