[BUG] VS Code extension activation fails on Windows 2.1.51

Status Fixed / completed
Reported on v2.1.51
Maintainer reply None cached
Activity 5 comments · opened Feb 24, 2026 · closed Feb 25, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Extension fails to activate on Windows 11.
Error in Developer Tools console:
Activating extension 'Anthropic.claude-code' failed:
Received 'file:///home/runner/work/claude-cli-internal/claude-cli-internal/build-agent-sdk/sdk.mjs'.

This causes: Error: command 'claude-vscode.editor.openLast' not found

Version: 2.1.51-win32-x64
OS: Windows 11

What Should Happen?

Extension should activate successfully and register commands including claude-vscode.editor.openLast.

Error Messages/Logs

Activating extension 'Anthropic.claude-code' failed: 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'.

Error: command 'claude-vscode.editor.openLast' not found

Steps to Reproduce

  1. Install Claude Code VS Code extension 2.1.51 on Windows 11
  2. Open VS Code
  3. Error appears immediately on startup

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

Unknown

Claude Code Version

2.1.51-win32-x64

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

6 Comments

github-actions[bot] · 7 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/28054
  2. https://github.com/anthropics/claude-code/issues/28073
  3. https://github.com/anthropics/claude-code/issues/28100

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

thoomi2009 · 7 months ago

升级到 2.1.52 同时升级一下 插件 就OK

adamrossmyers-coder · 7 months ago

Confirming this issue persists in v2.1.55 (win32-x64). The hardcoded CI paths were not fixed.

Details

extension.js in v2.1.55 contains 3 hardcoded references to the CI build path:

  1. createRequire("file:///home/runner/work/claude-cli-internal/claude-cli-internal/build-agent-sdk/sdk.mjs") (~byte 438942)
  2. fileURLToPath("file:///home/runner/work/claude-cli-internal/claude-cli-internal/build-agent-sdk/sdk.mjs") (~byte 844944)
  3. __dirname="/home/runner/work/claude-cli-internal/claude-cli-internal/packages/claude-vscode/src/extension" (~byte 1045972)

Workaround

Manually patching all 3 resolves the issue and the extension activates successfully:

# Backup first
cp extension.js extension.js.bak

# Fix createRequire/fileURLToPath paths
sed -i 's|file:///home/runner/work/claude-cli-internal/claude-cli-internal/build-agent-sdk/sdk.mjs|file:///c:/path/to/your/extension/extension.js|g' extension.js

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

Replace c:/path/to/your/extension/ with your actual extension path (e.g., c:/Users/<you>/.vscode/extensions/anthropic.claude-code-2.1.55-win32-x64/).

Environment: Windows 11 Home 10.0.26200, VS Code latest stable, extension v2.1.55 win32-x64.

samtuckerdavis · 7 months ago

Confirming regression in v2.1.55 (win32-x64) + complete fix

This issue persists in v2.1.55. The extension still ships with 3 hardcoded Linux CI build paths in extension.js that crash Module.createRequire() on Windows.

Error

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 Module.createRequire (node:internal/modules/cjs/loader:1915:13)
    at Object.<anonymous> (extension.js:45:4848)

Root cause

The CI build (home/runner/work/claude-cli-internal/) bakes absolute Linux paths into the minified bundle in 3 places:

  1. BE.createRequire("file:///home/runner/work/.../sdk.mjs") — crashes on activation (line 45)
  2. JE.fileURLToPath("file:///home/runner/work/.../sdk.mjs") — crashes on agent SDK invocation (line 100)
  3. __dirname="/home/runner/work/.../packages/claude-vscode/src/extension" — wrong directory resolution

Fix (bash, works in Git Bash / WSL / MSYS2)

EXT="$USERPROFILE/.vscode/extensions/anthropic.claude-code-2.1.55-win32-x64/extension.js"

# Backup
cp "$EXT" "$EXT.bak"

# Fix 1: createRequire with invalid Linux URL → use __filename
sed -i 's|BE.createRequire("file:///home/runner/work/claude-cli-internal/claude-cli-internal/build-agent-sdk/sdk.mjs")|BE.createRequire(__filename)|g' "$EXT"

# Fix 2: fileURLToPath with invalid Linux URL → use __filename directly
sed -i 's|JE.fileURLToPath("file:///home/runner/work/claude-cli-internal/claude-cli-internal/build-agent-sdk/sdk.mjs")|__filename|g' "$EXT"

# Fix 3: hardcoded __dirname → derive from __filename
sed -i 's|__dirname="/home/runner/work/claude-cli-internal/claude-cli-internal/packages/claude-vscode/src/extension"|__dirname=require("path").dirname(__filename)|g' "$EXT"

Then reload: Ctrl+Shift+P → Developer: Reload Window

Suggested build fix

The build pipeline should replace these paths with platform-agnostic equivalents (__filename, __dirname, import.meta.url) before bundling. This has now regressed across at least v2.1.51, 2.1.53, and 2.1.55.

Environment: Windows 11 Pro 10.0.26200, VS Code latest stable, Claude Code v2.1.55 win32-x64

shawnm-anthropic · 7 months ago

Thank you for your patience, v2.1.56 fixes the VS Code crash.

github-actions[bot] · 7 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.