Skip to content

feat: handle Docker/no-HOME env gracefully — plugin cache /tmp fallback, telemetry skip#375

Merged
theoephraim merged 2 commits intosupport-xdg-config-homefrom
copilot/sub-pr-352
Mar 12, 2026
Merged

feat: handle Docker/no-HOME env gracefully — plugin cache /tmp fallback, telemetry skip#375
theoephraim merged 2 commits intosupport-xdg-config-homefrom
copilot/sub-pr-352

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 12, 2026

When running in Docker without HOME set, os.homedir() returns /dev/null. The plugin cache had no fallback (breaking plugin loading), and telemetry would gracefulExit(1) instead of skipping cleanly.

Changes

user-config-dir.ts

  • getUserVarlockDir() returns string | nullnull when os.homedir() === '/dev/null'
  • New getPluginCacheDir(): returns <userVarlockDir>/plugins-cache normally, falls back to <tmpdir>/varlock-plugins-cache so plugin downloads always have a writable location

plugins.ts

  • Switched to getPluginCacheDir() — picks up the /tmp fallback automatically

telemetry.ts

  • checkIsOptedOut() returns true early when no home dir — telemetry silently skipped
  • All file ops (loadVarlockConfig, getAnonymousId) null-guarded
  • Removed gracefulExit(1) for the Docker no-HOME case

telemetry.command.ts

  • Throws a clear CliExitError when HOME is unset, with instructions to set HOME or XDG_CONFIG_HOME

Tests

  • user-config-dir.test.ts covers all three getUserVarlockDir() resolution cases (XDG, legacy ~/.varlock, default ~/.config/varlock) plus the Docker null case and getPluginCacheDir() /tmp fallback

Note on Docker persistence: the /tmp fallback is not preserved across container restarts. To avoid repeated plugin downloads, mount a volume at the cache path or set HOME/XDG_CONFIG_HOME to a persistent directory.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 12, 2026

⚠️ No Changeset found

Latest commit: e04ef60

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

…try graceful skip

Co-authored-by: theoephraim <1158956+theoephraim@users.noreply.github.com>
Copilot AI changed the title [WIP] [#348] Add support for $XDG_CONFIG_HOME for user config directory feat: handle Docker/no-HOME env gracefully — plugin cache /tmp fallback, telemetry skip Mar 12, 2026
@theoephraim theoephraim marked this pull request as ready for review March 12, 2026 00:51
@theoephraim theoephraim merged commit 27c57fd into support-xdg-config-home Mar 12, 2026
2 checks passed
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.

3 participants