Skip to content

Update data and config dir resolution to follow XDG base directories - #179

Open
santhiprakash wants to merge 3 commits into
unstablebuild:mainfrom
santhiprakash:fix/157-xdg-base-dirs
Open

santhiprakash wants to merge 3 commits into
unstablebuild:mainfrom
santhiprakash:fix/157-xdg-base-dirs

Conversation

@santhiprakash

Copy link
Copy Markdown
Contributor

Fixes #157.

Rune created ~/.rune on first launch and kept every piece of state in
it, cluttering the home directory. This follows the XDG base directory
convention on Linux and macOS while keeping every existing install
working unchanged:

  • Config resolves under $XDG_CONFIG_HOME/rune (default
    ~/.config/rune); data under $XDG_DATA_HOME/rune (default
    ~/.local/share/rune). An existing ~/.rune keeps being used — no
    migration — and -c/-d keep their meanings: an explicit -d still
    colocates the config with the chosen data directory so tests and
    .runedev workflows are untouched.

Resolution order, per the issue:

  • config: -c → <datadir>/config.yaml when -d is explicit →
    legacy ~/.rune/config.yaml/config.star when present →
    $XDG_CONFIG_HOME/rune/config.yaml
  • data: -d → legacy ~/.rune when present → $XDG_DATA_HOME/rune

While untangling the flag defaults, resolution fixes two latent bugs:

  • defaultConfigPath was resolved in init() before defaultDataPath
    was assigned, so the default -c value was computed against an empty
    data dir.
  • isBootstrapped and writePresetConfig hard-coded
    <datadir>/config.yaml, so a config living anywhere else — an
    explicit -c already today, or the XDG config dir now — re-ran the
    bootstrap on every launch, and the preset write landed somewhere the
    resolver never reads. Bootstrap now checks and writes the resolved
    config path.

Hard-coded ~/.rune paths that bypassed -d now follow the resolved
data dir:

  • rune.star log_path → $RUNE_DATADIR/debug.log. This also fixes
    the crash reporter, which reads <datadir>/debug.log while the log
    writer used ~/.rune.
  • RUNE_DATADIR is exported before mode dispatch instead of only
    during GUI setup, so headless and TUI configs expand log_path and
    package paths the same way.
  • The rune-agent skills list resolves $RUNE_DATADIR/skills, and the
    Zig extension's well-known fallbacks probe $RUNE_INSTALLDIR/bin
    (the install root the workspace host provisions under, which is what
    the extension env carries for remote workspaces).

For ssh:// workspaces the client sends the data dir relative to the
local home (~/.local/share/rune, ~/.runedev) instead of just the
basename, so the remote rune -x server installs packages under the
same home-relative path. A data dir outside the local home falls back
to ~/<basename> as before. Known limitations per the issue: a custom
remote XDG_DATA_HOME is ignored, and a remote with an existing
~/.rune reinstalls its packages once.

Docs updated: config, headless, network, wallpaper, packages,
extensions, tutorials, zig, agent {config, skills, claude-code}, the
sample config, the bug-report template, the Debian man page, and the
Homebrew cask zap lists (which now trash the XDG locations as well as
a legacy ~/.rune). The Docker image's ~/.rune references stay: its
Dockerfile pre-creates the directory, so the legacy path remains live
in-container.

testing

  • TestResolveDefaultDataPath and TestResolveConfigPath cover the
    full matrix table-driven: explicit -c, explicit -d (config
    follows it, preferring an existing config.star), legacy ~/.rune
    with and without configs, XDG_CONFIG_HOME/XDG_DATA_HOME set and
    unset, and relative XDG values ignored.
  • TestIsBootstrappedFollowsConfigPath and
    TestWritePresetConfigUsesResolvedConfigPath pin the bootstrap
    config-path regression — red on the previous handler, green now.
  • TestInstallRoot and TestConnectSchemeRemoteDataDirHomeRelative
    cover the home-relative remote guess and the out-of-home
    ~/<basename> fallback.
  • xvfb-run -a go test on every touched package: ok. xvfb-run -a make test shows only pre-existing environment failures in this sandbox
    (gemini's live-API-key tests, which fail identically on main, and an
    internal/text/textrpc flake that passes standalone and under
    -race). make lint clean.

Authorship

  • Written by hand. I would like a human review.
  • Mostly or partially generated by an AI agent, which I reviewed and understand.

Rune created ~/.rune on first launch and kept every piece of state in it,
cluttering the home directory. On fresh installs the config file now
resolves under $XDG_CONFIG_HOME/rune (default ~/.config/rune) and the data
directory under $XDG_DATA_HOME/rune (default ~/.local/share/rune). An
existing ~/.rune keeps working unchanged, and -c/-d keep their meanings:
an explicit -d still colocates the config with the chosen data directory.

While untangling the flag defaults, resolution also fixes two latent
bugs: defaultConfigPath was previously resolved before defaultDataPath
was assigned, and bootstrap detection and preset writes hard-coded
dataDir/config.yaml, so a config living elsewhere (an explicit -c, or
now the XDG config dir) re-ran bootstrap on every launch.

$RUNE_DATADIR is exported before mode dispatch instead of only during
GUI setup, so headless and TUI configs expand log_path and package paths
the same way. The bundled rune.star, the rune-agent skills list, and the
Zig extension's well-known fallbacks now resolve through it
(RUNE_INSTALLDIR for the workspace host's install root).

For ssh:// workspaces the client sends the data dir relative to the
local home (e.g. ~/.local/share/rune, ~/.runedev) instead of just the
basename, so the remote `rune -x` installs under the same home-relative
path. A data dir outside the local home falls back to ~/<basename>.

Signed-off-by: Santhi Prakash <b.santhiprakash@gmail.com>
@codecov-commenter

codecov-commenter commented Oct 6, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 86.00000% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/rune/main.go 90.00% 3 Missing ⚠️
cmd/rune/bootstrap_handler.go 71.42% 2 Missing ⚠️
internal/ide/workspace_handler.go 90.00% 1 Missing ⚠️
internal/workspace/workspacessh/scheme.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@santhiprakash
santhiprakash force-pushed the fix/157-xdg-base-dirs branch from d372d55 to 159df7c Compare October 6, 2026 14:13
@santhiprakash
santhiprakash force-pushed the fix/157-xdg-base-dirs branch 2 times, most recently from 3476c0c to 645805c Compare November 17, 2026 19:56
The macos-15 job on 645805c was cancelled about 15 minutes in with no
failed steps, and the same tree passed this job on the previous head.
This empty commit retriggers the pull_request checks.

Signed-off-by: Santhi Prakash <b.santhiprakash@gmail.com>
The ubuntu-24.04 job failed on TestUpAfterLogout in internal/runenet, a timing-sensitive integration test this change does not touch; the identical tree passed the same job on the previous head. Retrigger checks.

Signed-off-by: Santhi Prakash <b.santhiprakash@gmail.com>
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.

Follow XDG base directories instead of creating ~/.rune

2 participants