[BUG] VS Code extension v2.1.51 fails to activate on Windows — hardcoded Linux CI paths in extension.js

Resolved 💬 4 comments Opened Feb 24, 2026 by echo-of-machines Closed Feb 24, 2026

Description

The Claude Code VS Code extension v2.1.51 fails to activate on Windows with a TypeError because extension.js contains three hardcoded Linux CI build paths from the GitHub Actions runner environment.

Error

From exthost.log:

Extension activation failure: Anthropic.claude-code
TypeError: The argument 'filename' must be a file URL object, file URL string, or absolute path string.
  Received 'file:///home/runner/work/claude-cli-internal/claude-cli-internal/build-agent-sdk/sdk.mjs'
    at Object.<anonymous> (extension.js:45:4602)

The user-facing symptom is: command 'claude-vscode.editor.openLast' not found — because the extension never activates, no commands are registered.

Root Cause

The bundler (likely esbuild) replaced runtime path variables with static string literals at build time, using the CI runner's filesystem paths instead of keeping them dynamic. Three occurrences in extension.js:

  1. createRequire("file:///home/runner/work/claude-cli-internal/claude-cli-internal/build-agent-sdk/sdk.mjs")

Node's createRequire() rejects this on Windows — file:///home/runner/... is not a valid Windows file URL (no drive letter).

  1. Ye("file:///home/runner/work/claude-cli-internal/claude-cli-internal/build-agent-sdk/sdk.mjs")

Fallback path for resolving the Claude executable — also invalid on Windows.

  1. var __dirname="/home/runner/work/claude-cli-internal/claude-cli-internal/packages/claude-vscode/src/extension"

The bundler replaced the dynamic __dirname with a hardcoded string pointing to the CI runner's filesystem.

Environment

  • OS: Windows 11 Pro 10.0.26200
  • Editor: Cursor 2.5.24 (VS Code fork)
  • Extension version: anthropic.claude-code@2.1.51 (win32-x64)
  • Claude Code CLI: 2.1.51

Workaround

Manually patch extension.js by replacing the three hardcoded paths:

cd ~/.cursor/extensions/anthropic.claude-code-2.1.51-win32-x64  # or ~/.vscode/extensions/...

# 1. Fix createRequire
sed -i 's|eG.createRequire("file:///home/runner/work/claude-cli-internal/claude-cli-internal/build-agent-sdk/sdk.mjs")|eG.createRequire(__filename)|g' extension.js

# 2. Fix Ye() executable path fallback
sed -i 's|Ye("file:///home/runner/work/claude-cli-internal/claude-cli-internal/build-agent-sdk/sdk.mjs")|__filename|g' extension.js

# 3. Fix __dirname
sed -i 's|var __dirname="/home/runner/work/claude-cli-internal/claude-cli-internal/packages/claude-vscode/src/extension"|var __dirname=require("path").dirname(__filename)|g' extension.js

Suggested Fix

The build configuration should preserve dynamic __dirname / __filename resolution rather than replacing them with static strings. For esbuild, this can be done with the define or banner options, or by using platform: 'node' which keeps these globals intact.

View original on GitHub ↗

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