Skip to content

fix(paths): use XDG Base Directory for config on Linux#12255

Open
sumaiazaman wants to merge 2 commits intocontinuedev:mainfrom
sumaiazaman:fix/xdg-config-dir-linux
Open

fix(paths): use XDG Base Directory for config on Linux#12255
sumaiazaman wants to merge 2 commits intocontinuedev:mainfrom
sumaiazaman:fix/xdg-config-dir-linux

Conversation

@sumaiazaman
Copy link
Copy Markdown

@sumaiazaman sumaiazaman commented Apr 29, 2026

Summary

Fixes #5397.

On Linux, most distributions expect user configuration to live in ~/.config/ (or $XDG_CONFIG_HOME) rather than directly in the home directory.

This change makes Continue follow the XDG Base Directory Specification on Linux:

Condition Path used
XDG_CONFIG_HOME is set $XDG_CONFIG_HOME/continue
XDG_CONFIG_HOME is not set ~/.config/continue
~/.continue already exists (existing install) ~/.continue ← unchanged

macOS and Windows behaviour is unchanged — they continue using ~/.continue.

Backward compatibility

Existing Linux users with a ~/.continue directory are not affected — the legacy path is detected at startup and used as-is. No data is moved without user action.

New Linux installations will automatically get the XDG-compliant path.

Changes

  • core/util/paths.ts — extracted getDefaultContinueGlobalDir() helper that encapsulates the platform/XDG logic, wired into CONTINUE_GLOBAL_DIR
  • core/util/paths.test.ts — unit tests covering all four cases (Linux+XDG, Linux+default, Linux+legacy fallback, macOS, Windows)

Summary by cubic

Switches the default config directory on Linux to follow the XDG Base Directory spec: $XDG_CONFIG_HOME/continue or ~/.config/continue. Existing ~/.continue installs are preserved, and macOS/Windows behavior is unchanged.

  • Bug Fixes
    • Added getDefaultContinueGlobalDir for platform-aware paths with legacy ~/.continue fallback.
    • Validates XDG_CONFIG_HOME (non-empty absolute only); falls back to ~/.config otherwise.
    • Uses recursive fs.mkdirSync in getContinueGlobalPath to create missing parent dirs.
    • Added unit tests for Linux (XDG set/unset, empty/relative, legacy), macOS, and Windows.

Written for commit 65d065a. Summary will update on new commits. Review in cubic

On Linux, the default Continue global directory now follows the XDG
Base Directory Specification:

- $XDG_CONFIG_HOME/continue when XDG_CONFIG_HOME is set
- ~/.config/continue otherwise

Existing installations are not affected: if ~/.continue already exists
the legacy path continues to be used, so no data is relocated without
user action.

macOS and Windows behaviour is unchanged.

Fixes continuedev#5397
@sumaiazaman sumaiazaman requested a review from a team as a code owner April 29, 2026 14:40
@sumaiazaman sumaiazaman requested review from sestinj and removed request for a team April 29, 2026 14:40
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 29, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@sumaiazaman
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="core/util/paths.ts">

<violation number="1" location="core/util/paths.ts:52">
P2: XDG_CONFIG_HOME is used without validating empty/relative values, so Linux config can be created in the working directory instead of the user config dir.</violation>

<violation number="2" location="core/util/paths.ts:53">
P2: Linux now defaults to a nested config directory, but the directory creation code still uses non-recursive `fs.mkdirSync`, which can throw when parent directories are missing.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread core/util/paths.ts Outdated
Comment thread core/util/paths.ts
Two issues flagged in code review:

1. XDG_CONFIG_HOME was used without validation. An empty string or
   relative path would place the config directory in the working
   directory instead of the user config dir. Now only non-empty
   absolute paths are accepted; anything else falls back to
   ~/.config.

2. getContinueGlobalPath used fs.mkdirSync without { recursive: true }.
   On a fresh Linux install ~/.config may not exist yet, causing a
   ENOENT crash when the XDG path is first created. Switching to
   recursive mode creates all missing parent directories.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Default Linux Config Directory Should Be .config/continue

1 participant