VS Code extension crashes with ENOENT when virtual/remote workspace (GitHub Repositories) is open
Bug Description
The Claude Code VS Code extension throws ENOENT: no such file or directory, lstat '/<username>' when a GitHub remote repository (or any virtual filesystem workspace) is open in VS Code.
Steps to Reproduce
- Open VS Code with a GitHub remote repository (e.g., via the GitHub Repositories extension /
vscode-vfs://) - Install the Claude Code extension
- Click to open the Claude Code panel
Error
Error: ENOENT: no such file or directory, lstat '/<username>'
at Object.realpathSync (node:fs:2805:29)
at Object.<anonymous> (node:electron/js2c/node_init:2:5760)
at WQ.setupPanel (.../anthropic.claude-code-2.1.86-darwin-arm64/extension.js:803:12985)
at WQ.createPanel (.../anthropic.claude-code-2.1.86-darwin-arm64/extension.js:803:12542)
Root Cause
In extension.js, the methods setupPanel, resolveWebviewView, and resolveSessionListView all contain this pattern:
let G = vscode.workspace.workspaceFolders?.map((q) => q.uri.fsPath) || [];
let x = fs.realpathSync(G[0] || os.homedir()).normalize("NFC");
When a virtual/remote workspace is open (e.g., a GitHub repo via the Remote Repositories extension), G[0] is a virtual path like /<username>/<repo-name> — not a real filesystem path. Calling fs.realpathSync() on it fails with ENOENT because the path doesn't exist on disk.
Fix
Wrap the realpathSync call in a try-catch and fall back to os.homedir():
let x = (() => {
try {
return fs.realpathSync(G[0] || os.homedir());
} catch (e) {
return os.homedir();
}
})().normalize("NFC");
This fix needs to be applied in all three methods: setupPanel, resolveWebviewView, and resolveSessionListView.
Environment
- Claude Code extension: 2.1.86
- VS Code: latest
- OS: macOS (darwin-arm64)
- Reproduced when a GitHub remote repository is open via
ms-vscode.remote-repositories
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗