[BUG] command 'claude-vscode.editor.openLast' not found
Resolved 💬 16 comments Opened Feb 24, 2026 by JokerMartini Closed Feb 24, 2026
💡 Likely answer: A maintainer (blois, collaborator)
responded on this thread — see the highlighted reply below.
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?
When launching vs code and clicking on the Claude Code icon i get this error: command 'claude-vscode.editor.openLast' not found
What Should Happen?
The claude code panel should open when i click it's icon in the toolbar.
Error Messages/Logs
command 'claude-vscode.editor.openLast' not found
Steps to Reproduce
- Open vs code
- Open a folder/workspace
- Click the Claude code icon
- Step 3 produces and error and never opens cluade
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.51
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
16 Comments
Got the same issue...
Found 1 possible duplicate issue:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
me too
2.1.51
I found a temporary workaround is to downgrade the VSCode Claude Code Extension to version
2.1.49for now.Found the error in developer tools
__mainThreadExtensionService.ts:108__ 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__'.$onExtensionActivationError@__mainThreadExtensionService.ts:108__
Just uninstall and install older version as @CPR03 says. Works for now.
Workaround: Downgrade to v2.1.49
Environment: Windows 11, VS Code, Claude Code extension v2.1.51
Problem
After a crash, the extension stopped working entirely with the error:
The extension fails to load when it can't restore a previous session, making it completely unusable.
What I tried (did NOT fix the issue)
Ctrl+Shift+P→Developer: Reload Window) — Error persisted.globalStorageatC:\Users\<user>\AppData\Roaming\Code\User\globalStorage\— Theanthropic.claude-codefolder didn't exist, meaning the extension never re-initialized after the crash.C:\Users\<user>\.vscode\extensions\anthropic.claude-code-*.AppData\Roaming\Code\CacheandCachedData).What fixed it
Downgrading to v2.1.49:
Ctrl+Shift+X) → Click on Claude Code.The extension loaded correctly after the downgrade.
Suggestion
I'd recommend disabling auto-update for the extension to prevent it from updating back to the broken version:
This seems to be a regression in v2.1.51 where the session restore logic doesn't handle missing or corrupted state gracefully.
Used Claude to Fix Claude, works great.
<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 `
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
what VSCode version is this happening on?
1.109.5 stable
Commit: 072586267e68ece9a47aa43f8c108e0dcbf44622
1.110.0-insider
Commit: 62028559c1ca63edaa7fd32d3845ea502af07ab2
I had this issue: command 'claude-vscode.editor.open' not found and this was working for me:
Workaround: Patch extension.js in-place (no downgrade needed)
Root cause: extension.js line 45 calls createRequire() with a hardcoded Linux CI path that Windows rejects:
createRequire("file:///home/runner/work/claude-cli-internal/claude-cli-internal/build-agent-sdk/sdk.mjs")
Fix: Replace it with createRequire(__filename). This is safe because the resulting require function (H1) is only used for Node.js built-ins (fs, path,
child_process, stream), so the base path is irrelevant.
Steps (Windows):
# Backup
cp "%USERPROFILE%\.vscode\extensions\anthropic.claude-code-2.1.51-win32-x64\extension.js" \
"%USERPROFILE%\.vscode\extensions\anthropic.claude-code-2.1.51-win32-x64\extension.js.bak"
# Patch
sed -i 's|createRequire("file:///home/runner/work/claude-cli-internal/claude-cli-internal/build-agent-sdk/sdk.mjs")|createRequire(__filename)|g' \
"%USERPROFILE%\.vscode\extensions\anthropic.claude-code-2.1.51-win32-x64\extension.js"
Or manually find/replace in the file:
Reload VS Code after patching. Confirmed working on Windows 11 + VS Code 1.109.5 + Claude Code 2.1.51.
It looks the issue has been resolved since 2.1.52, 13minutes ago.
Hi, sorry about the disruption. We just published v2.1.52 which should hopefully work better.
Still getting this issue
Version 2.1.55 also has this problem
fixed on 2.1.56
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.