Skip to content

feat: support RDT_CONFIG_DIR and XDG_CONFIG_HOME for config path override#6

Open
cestivan wants to merge 1 commit intopublic-clis:mainfrom
cestivan:feat/xdg-config-dir
Open

feat: support RDT_CONFIG_DIR and XDG_CONFIG_HOME for config path override#6
cestivan wants to merge 1 commit intopublic-clis:mainfrom
cestivan:feat/xdg-config-dir

Conversation

@cestivan
Copy link

Problem

The config directory is currently hardcoded to ~/.config/rdt-cli:

CONFIG_DIR = Path.home() / ".config" / "rdt-cli"

This causes two issues:

  1. Multi-instance isolation — when multiple independent processes (e.g. automated agents, CI jobs, or per-user instances) run on the same machine, they all read/write the same credential file. This leads to credential collisions and unintended sharing.
  2. XDG non-compliance — the XDG Base Directory spec is the standard way for users to relocate config on Linux/macOS, but rdt-cli ignores XDG_CONFIG_HOME.

Solution

Resolve the config directory using a priority chain with no breaking change:

Priority Source Example
1 RDT_CONFIG_DIR env var RDT_CONFIG_DIR=/tmp/myagent/rdt rdt whoami
2 XDG_CONFIG_HOME/rdt-cli XDG_CONFIG_HOME=~/.config-work rdt whoami
3 ~/.config/rdt-cli existing default — unchanged

The implementation is a small helper function in constants.py:

def _resolve_config_dir() -> Path:
    if rdt_dir := os.environ.get("RDT_CONFIG_DIR"):
        return Path(rdt_dir)
    if xdg_home := os.environ.get("XDG_CONFIG_HOME"):
        return Path(xdg_home) / "rdt-cli"
    return Path.home() / ".config" / "rdt-cli"

Changes

  • rdt_cli/constants.py — introduce _resolve_config_dir(), replace the hardcoded path
  • README.md — document RDT_CONFIG_DIR and XDG_CONFIG_HOME in the Environment Variables table; link the Authentication section to it

Backwards compatibility

No breaking change. When neither env var is set, the resolved path is identical to the previous hardcoded value.

…ride

Fixes the hardcoded config path (~/.config/rdt-cli) by resolving the
config directory using the following priority:

1. RDT_CONFIG_DIR env var — explicit full path override; useful for
   multi-user/multi-agent environments where each instance must have
   isolated credentials and must not share config with others.
2. XDG_CONFIG_HOME/rdt-cli — standard XDG Base Directory spec,
   already expected by users on Linux and macOS.
3. ~/.config/rdt-cli — existing default, unchanged as final fallback.

No breaking change: behaviour is identical when neither env var is set.

Also updates README to document the two new environment variables and
links the authentication section to the env vars table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant