microsoft / microsoft/vscode

Agent Host fails to start when XDG_RUNTIME_DIR is unavailable in WSL

Open
#336,161 0 comments 0 reactions 1 assignee Claimed by @sandy081 View on GitHub
triage-needed
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

After rebooting a WSL Ubuntu environment, `XDG_RUNTIME_DIR` still pointed to `/run/user/1000`, but that directory did not exist. The VS Code agent host tried to listen on `/run/user/1000/vscode-ipc-*.sock` and logged `EACCES`. Native agent chats and Codex sessions did not appear in the VS Code window, although their session data was still present on disk.

Starting the user's systemd service recreated `/run/user/1000`; reopening the window then loaded the sessions. Reloading the window before that did not help.

`createRandomIPCHandle()` currently selects `XDG_RUNTIME_DIR` whenever the variable is set. It does not check whether the directory exists or can be used for a socket. When the directory is unavailable, it should use the same temporary-directory fallback it already uses when the variable is unset.

- VS Code: 1.137.0 (`645f29cc3176500b4b5762ba887cf2a7f0ffdf2c`)
- Remote OS: Ubuntu in WSL, arm64
- Feature: agent-host startup and session list
- Observed log: `listen EACCES /run/user/1000/vscode-ipc-*.sock`

Steps to reproduce:

1. In a Linux remote environment, set `XDG_RUNTIME_DIR` to a path that does not exist (as happened after this WSL reboot).
2. Start a VS Code agent-host session.
3. Observe that socket creation fails and the session list does not load.

This differs from #157275, which reports a stale CLI socket path after a socket was created.

[Patch collection documentation](https://github.com/RyanEwen/vscode-patches/blob/main/docs/patches/vscode-336162.md)

*AI disclosure: this issue and the related code were written with the assistance of AI.*

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.