[BUG] command 'claude-vscode.editor.openLast' not found Extension fails to activate on Windows - hardcoded Linux path in sdk.mjs

Status Fixed / completed
Reported on v2.1.51
Maintainer reply None cached
Activity 9 comments · opened Feb 24, 2026 · closed Feb 24, 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 Anthropic.claude-code version 2.1.51 fails to activate on Windows with the following 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'
The extension bundle contains a hardcoded Linux build path (/home/runner/work/...) which is invalid on Windows, causing the extension to fail on every activation attempt.
Environment:

OS: Windows 10/11
VS Code version: (isi versi VS Code kamu)
Extension version: anthropic.claude-code-2.1.51-win32-x64

Steps to reproduce:

Install Claude Code extension v2.1.51 on Windows
Open any workspace in VS Code
Extension fails to activate

Expected behavior:
Extension activates successfully on Windows.
Actual behavior:
Extension fails to activate on every startup. The command claude-vscode.editor.openLast shows as "not found" because the extension never successfully loads.

What Should Happen?

The extension should activate successfully on Windows and all commands
(including claude-vscode.editor.openLast) should be available for use.

Error Messages/Logs

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> (c:\Users\USer\.vscode\extensions\anthropic.claude-code-2.1.51-win32-x64\extension.js:45:4602)

Steps to Reproduce

  1. Install Claude Code extension v2.1.51 on Windows
  2. Open any workspace in VS Code
  3. Extension fails to activate - error appears in exthost log
  4. All claude-vscode commands show as "not found"

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.51

Claude Code Version

2.1.51

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

VS Code integrated terminal

Additional Information

The extension bundle contains a hardcoded Linux CI build path
(/home/runner/work/claude-cli-internal/...) inside extension.js
which is invalid on Windows. This causes the extension to fail on
every activation attempt. Reinstalling does not fix the issue.

View original on GitHub ↗

9 Comments

StealUrKill · 6 months ago

Used Claude to Fix Claude, works great.

PS C:\Users\HSS> powershell.exe -ExecutionPolicy Bypass -File .\fix-claude-code-extension.ps1 Found 1 Claude Code extension(s): [anthropic.claude-code-2.1.51-win32-x64] Found 2 occurrence(s) of the bad CI path. Patching... [anthropic.claude-code-2.1.51-win32-x64] Backup saved -> extension.js.bak [anthropic.claude-code-2.1.51-win32-x64] Fix 1 (createRequire): replaced 1 occurrence(s) [anthropic.claude-code-2.1.51-win32-x64] Fix 2 (path resolver): replaced 1 occurrence(s) [anthropic.claude-code-2.1.51-win32-x64] Patched successfully Done. Reload VSCode to apply: Ctrl+Shift+P -> 'Developer: Reload Window'

<img width="232" height="217" alt="Image" src="https://github.com/user-attachments/assets/f40b30da-23e8-4174-bf99-da8ba0a5b9fe" />

```# fix-claude-code-extension.ps1
#

Fixes Claude Code VSCode extension activation failure on Windows.

#

Error:

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/...'

#

Root cause:

The extension bundle contains two hardcoded Linux CI build paths

(file:///home/runner/work/...). On Windows, Node.js rejects these

URLs in fileURLToPath() because they have no Windows drive letter.

This crashes the extension immediately at activation.

#

What this script patches:

Fix 1 - createRequire call: crashes at activation time

.createRequire("file:///home/runner/.../sdk.mjs")

-> .createRequire(__filename) (use actual file path instead)

#

Fix 2 - path resolution call: crashes when agent SDK is invoked

SomeFunc("file:///home/runner/.../sdk.mjs")

-> inline child_process lookup for the claude CLI on PATH

#

Usage:

Right-click -> "Run with PowerShell"

OR from a PowerShell prompt: .\fix-claude-code-extension.ps1

$ErrorActionPreference = "Stop"

$extensionRoot = "$env:USERPROFILE\.vscode\extensions"
$badUrl = 'file:///home/runner/work/claude-cli-internal/claude-cli-internal/build-agent-sdk/sdk.mjs'

---- Regex patterns (stable across minified versions) ----

Fix 1: .createRequire("file:///home/...sdk.mjs")

The method name createRequire is stable even in minified code.

$pattern1 = '\.createRequire\("file:///home/runner/work/claude-cli-internal/claude-cli-internal/build-agent-sdk/sdk\.mjs"\)'
$replacement1 = '.createRequire(__filename)'

Fix 2: anyMinifiedName("file:///home/...sdk.mjs")

After fix 1 removes the createRequire case, any remaining call

with this URL is the fileURLToPath wrapper (Ye or similar).

Replace it with an inline lookup that finds the claude CLI on PATH.

$pattern2 = '[a-zA-Z_$][a-zA-Z0-9_$]*\("file:///home/runner/work/claude-cli-internal/claude-cli-internal/build-agent-sdk/sdk\.mjs"\)'
$replacement2 = '(function(){try{return(require("child_process").spawnSync(process.platform==="win32"?"where.exe":"which",["claude"],{encoding:"utf8"}).stdout||"").split(/[\r\n]+/).filter(Boolean)[0]}catch(e){}})()'

---- Find extension directories ----

if (-not (Test-Path $extensionRoot)) {
Write-Host "VSCode extensions directory not found: $extensionRoot" -ForegroundColor Red
exit 1
}

$dirs = Get-ChildItem $extensionRoot -Directory | Where-Object { $_.Name -like 'anthropic.claude-code-*' }

if ($dirs.Count -eq 0) {
Write-Host "No Claude Code extension found in: $extensionRoot" -ForegroundColor Yellow
exit 1
}

Write-Host "Found $($dirs.Count) Claude Code extension(s):`n"

foreach ($dir in $dirs) {
$label = $dir.Name
$file = Join-Path $dir.FullName 'extension.js'

if (-not (Test-Path $file)) {
Write-Host "[$label] extension.js not found, skipping" -ForegroundColor Yellow
continue
}

$content = [System.IO.File]::ReadAllText($file, [System.Text.Encoding]::UTF8)

if ($content.IndexOf($badUrl) -lt 0) {
Write-Host "[$label] Not affected (bad URL not found) - already patched or different version" -ForegroundColor Green
continue
}

# Count occurrences before patching
$count = ([regex]::Matches($content, [regex]::Escape($badUrl))).Count
Write-Host "[$label] Found $count occurrence(s) of the bad CI path. Patching..." -ForegroundColor Cyan

# Backup original
$backup = "$file.bak"
Copy-Item $file $backup
Write-Host "[$label] Backup saved -> extension.js.bak"

# Apply Fix 1: createRequire
$patched = [regex]::Replace($content, $pattern1, $replacement1)
$fix1count = $count - ([regex]::Matches($patched, [regex]::Escape($badUrl))).Count
Write-Host "[$label] Fix 1 (createRequire): replaced $fix1count occurrence(s)"

# Apply Fix 2: fileURLToPath wrapper
$patched2 = [regex]::Replace($patched, $pattern2, $replacement2)
$fix2count = ([regex]::Matches($patched, [regex]::Escape($badUrl))).Count `

  • ([regex]::Matches($patched2, [regex]::Escape($badUrl))).Count

Write-Host "[$label] Fix 2 (path resolver): replaced $fix2count occurrence(s)"

# Verify no bad URLs remain
$remaining = ([regex]::Matches($patched2, [regex]::Escape($badUrl))).Count
if ($remaining -gt 0) {
Write-Host "[$label] WARNING: $remaining occurrence(s) still remain after patching!" -ForegroundColor Yellow
}

# Write patched file
[System.IO.File]::WriteAllText($file, $patched2, [System.Text.Encoding]::UTF8)
Write-Host "[$label] Patched successfully" -ForegroundColor Green
Write-Host ""
}

Write-Host "Done. Reload VSCode to apply: Ctrl+Shift+P -> 'Developer: Reload Window'" -ForegroundColor White

github-actions[bot] · 6 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/28072

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

DiegoAR98 · 6 months ago

The fix above from StealUrKill works!

StealUrKill · 6 months ago
The fix above from StealUrKill works!

I would not lie lol.. Appreciate it though

xiazhichen24 · 6 months ago
Used Claude to Fix Claude, works great.

awesome!

shawnm-anthropic · 6 months ago

Hi, sorry about the disruption. We just published v2.1.52 which should hopefully work better.

trgiangvp3 · 6 months ago
Hi, sorry about the disruption. We just published v2.1.52 which should hopefully work better.

Hi, v2.1.53 is broken on Windows. Extension fails to activate because the build server path is not resolved.

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'

Obviously you hardcoded the CI/CD build path and forgot to replace it with the actual local path. Error at extension.js:45:4882 in createRequire.

2026-02-25 09:49:25.527 [error] Activating extension Anthropic.claude-code failed due to an error:
2026-02-25 09:49:25.527 [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> (c:\Users\trgia\.vscode\extensions\anthropic.claude-code-2.1.53-win32-x64\extension.js:45:4882)
at Module._compile (node:internal/modules/cjs/loader:1714:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1848:10)
at Module.load (node:internal/modules/cjs/loader:1448:32)
at Module._load (node:internal/modules/cjs/loader:1270:12)
at c._load (node:electron/js2c/node_init:2:17993)
at e._load (file:///c:/Users/trgia/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:405:6055)
at t._load (file:///c:/Users/trgia/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:223:22773)
at s._load (file:///c:/Users/trgia/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:215:24706)
at TracingChannel.traceSync (node:diagnostics_channel:328:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:244:24)
at Module.require (node:internal/modules/cjs/loader:1470:12)
at Module.require (c:\Users\trgia\.vscode\extensions\github.copilot-chat-0.37.8\dist\extension.js:382:36169)
at require (node:internal/modules/helpers:147:16)
at pee.Cb (file:///c:/Users/trgia/AppData/Local/Programs/Microsoft%20VS%20Code/072586267e/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:254:1256)

wish2323 · 6 months ago

I also had the same issue in version 2.1.56 in windows, and I took temporary measures as follwows:
`
The Issue

The Claude Code VSCode extension (v2.1.56-win32-x64) failed to activate on Windows with this error:

SyntaxError: The argument 'filename' must be a file URL object,
file URL string, or absolute path string.
Received 'file:///home/runner/work/...'

Root Cause

The bundled extension.js contained a hardcoded Linux CI build path from Anthropic's build pipeline:

let h0 = RW.fileURLToPath("file:///home/runner/work/claude-cli-internal/claude-cli-internal/build-agent-sdk/sdk.mjs"),
C3 = qD.join(h0, "..");
O = qD.join(C3, "cli.js")

This code resolves the SDK's file path, goes up one directory, and finds cli.js (the Claude CLI). On Linux/macOS this path might
work in CI, but on Windows, Node.js rejects it because file:///home/runner/... has no Windows drive letter (e.g. C:), causing
fileURLToPath() to crash immediately at activation.

The Fix

Replaced the entire broken path-resolution block with a runtime CLI lookup:

if(!O){
O = require("child_process")
.spawnSync(process.platform === "win32" ? "where.exe" : "which",
["claude"], {encoding: "utf8"})
.stdout.trim().split(/\r?\n/)[0]
}

Instead of deriving the CLI location from a hardcoded build path, it simply finds the claude executable on the system PATH using
where.exe (Windows) or which (Linux/macOS).

First Attempt (Failed)

The original PowerShell patch script used a regex [a-zA-Z_$][a-zA-Z0-9_$]*("file:///home/...") which only matched the method name
fileURLToPath(...) but not its object prefix RW., producing invalid JS: RW.(function(){...})().

Final Fix

Used a Node.js script for an exact string match-and-replace — no regex escaping issues, no partial matches. The backup file
(extension.js.bak) remains in the extension directory if you ever need to restore.`

github-actions[bot] · 5 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.