Skip to content

feat(config): follow XDG Base Directory spec for config location - #1503

Open
jared-outpost[bot] wants to merge 3 commits into
mainfrom
issue-1502-xdg-base-dir
Open

feat(config): follow XDG Base Directory spec for config location#1503
jared-outpost[bot] wants to merge 3 commits into
mainfrom
issue-1502-xdg-base-dir

Conversation

@jared-outpost

@jared-outpost jared-outpost Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Closes #1502

What

sentry-cli stored its config/data (the cli.db SQLite database with credentials and caches) in ~/.sentry, cluttering the home directory and breaking in environments that block writes to $HOME (e.g. sandboxed coding agents).

This makes the config directory follow the XDG Base Directory specification, matching how the CLI already resolves shell/completion paths.

Resolution precedence

getConfigDir() now resolves via a new pure resolveConfigDir(env, home) helper:

  1. SENTRY_CONFIG_DIR — explicit override, unchanged (highest priority)
  2. Legacy ~/.sentry — used when it already exists, so existing installs keep working with no migration
  3. $XDG_CONFIG_HOME/sentry — defaulting to ~/.config/sentry. A non-absolute XDG_CONFIG_HOME is ignored per the spec.

Changes

  • packages/cli/src/lib/db/index.ts — new exported resolveConfigDir(env, home) helper; getConfigDir() delegates to it.
  • packages/cli/test/lib/config.test.ts — unit tests covering all four precedence branches plus the non-absolute XDG_CONFIG_HOME case.
  • Docs updated: README.md, DEVELOPMENT.md, apps/cli-docs/src/fragments/configuration.md, apps/cli-docs/src/content/docs/getting-started.mdx.

Testing

vitest run test/lib/config.test.ts — 47 tests pass (5 new). Biome clean on changed files.

Note: binary install paths (~/.sentry/bin) are driven by the install script and left unchanged; this PR scopes to the config/data directory only.

Resolve the config/data directory via the XDG Base Directory
specification instead of always using `~/.sentry`. Precedence:

1. `SENTRY_CONFIG_DIR` override (unchanged, highest priority)
2. Legacy `~/.sentry` when it already exists (no breakage for
   existing installs)
3. `/sentry`, defaulting to `~/.config/sentry`

A non-absolute `XDG_CONFIG_HOME` is ignored per the spec. This keeps
credentials and caches out of the home directory root, which also
unblocks environments (e.g. coding agents) that restrict writes to
`/root`.

Fixes #1502
@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment 操作 Updated (UTC)
cli Ready Ready Preview Aug 28, 2026 6:04pm

Request Review

@jared-outpost
jared-outpost Bot marked this pull request as ready for review August 28, 2026 17:58
@jared-outpost

jared-outpost Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

CI green on the feature branch (check_suite success). Self-review clean. Marking ready and requesting review from the issue author.

@github-actions github-actions Bot added the risk: high PR risk score: high label Aug 28, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2c52b8d. Configure here.

Comment thread packages/cli/src/lib/db/index.ts
…onfig.json

A bare ~/.sentry/bin created by the curl installer should not prevent
new XDG-based installs. The legacy check now requires the presence of
the actual database or the old JSON config file.

Fixes the Cursor Bugbot report on PR #1503.
@BYK

BYK commented Aug 29, 2026

Copy link
Copy Markdown
Member

Jared, we need to do the following:

  1. Move the binary install path to either the new config directory or the appropriate directory based on the XDG Base Directory spec
  2. We should migrate the config directory instead of leaving it at the old place. The best place for this is the setup command I think

@jared-outpost

jared-outpost Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

ack — will update binary install paths to follow XDG (via resolveConfigDir) and add migration logic inside setup so legacy ~/.sentry moves to the new location on first run. expanding scope as requested.

@BYK

BYK commented Aug 29, 2026

Copy link
Copy Markdown
Member

Jared, update the patch already?

@jared-outpost

jared-outpost Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

working on it — expanding to XDG-aware binary paths + migration inside setup. will push the update shortly.

@jared-outpost

jared-outpost Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

yep, expanding the patch now to also move binary install paths to XDG (via XDG_BIN_HOME / ~/.local/bin) and add migration inside setup. will push the update.

@jared-outpost

jared-outpost Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

expanding the patch now to cover XDG binary paths + migration in setup. pushing shortly.

@jared-outpost

jared-outpost Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

not yet — expanding determineInstallDir + setup migration for binary paths now. will push once the XDG-aware logic + migration is in.

注册 for free to join this conversation on GitHub. Already have an account? 登录 to comment

标签

risk: high PR risk score: high

项目

None yet

Development

Successfully merging this pull request may close these issues.

Support XDG_BASE_DIRECTORY specification.

1 participant