VS Code extension crashes with ENOENT when virtual/remote workspace (GitHub Repositories) is open

Resolved 💬 2 comments Opened Mar 28, 2026 by jessusmach Closed Mar 28, 2026

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

  1. Open VS Code with a GitHub remote repository (e.g., via the GitHub Repositories extension / vscode-vfs://)
  2. Install the Claude Code extension
  3. 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

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗