[GH-ISSUE #113] install.ps1 deletes extensions.json and uninstall.ps1 corrupts it, destroying all extensions #81

Open
opened 2026-05-06 13:13:08 +02:00 by BreizhHardware · 5 comments

Originally created by @khuynh22 on GitHub (Mar 4, 2026).
Original GitHub issue: https://github.com/bwya77/vscode-dark-islands/issues/113

Description

After installing via install.ps1 and then uninstalling via uninstall.ps1 on Windows, all VS Code extensions are removed and no extensions can be installed or loaded. VS Code reports:

Invalid extensions content in vscode-userdata:/c%3A/Users/<user>/.vscode/extensions/extensions.json

Root Cause

There are two bugs — one in each script:

Bug 1: install.ps1 deletes extensions.json

https://github.com/bwya77/vscode-dark-islands/blob/main/install.ps1#L49-L53

$extJsonPath = "$env:USERPROFILE\.vscode\extensions\extensions.json"
if (Test-Path $extJsonPath) {
    Remove-Item $extJsonPath -Force
    Write-Host "Cleared extensions.json (VS Code will rebuild it)" -ForegroundColor Green
}

This deletes the extension registry outright. The comment says "previous versions of this script wrote invalid content to this file" — so the fix for the old bug was to just nuke the file. When VS Code rebuilds it, it only registers extensions it can discover on disk at startup, which may not include all previously installed extensions (e.g., extensions installed via marketplace that rely on proper metadata in this file).

Bug 2: uninstall.ps1 corrupts extensions.json via PowerShell serialization

https://github.com/bwya77/vscode-dark-islands/blob/main/uninstall.ps1#L37-L45

$extensions = @($extensions | Where-Object {
    $_.identifier.id -ne 'bwya77.islands-dark' -and
    $_.identifier.id -ne 'your-publisher-name.islands-dark'
})
if ($extensions.Count -lt $before) {
    $extensions | ConvertTo-Json -Depth 10 -Compress | Set-Content $extJsonPath

When only one extension remains after filtering out bwya77.islands-dark, PowerShell's ConvertTo-Json serializes it as a bare JSON object {...} instead of a JSON array [{...}]. This is a well-known PowerShell 5.1 gotcha — the @() array wrapper does not survive ConvertTo-Json for single-element arrays. VS Code expects extensions.json to be a JSON array and cannot parse the bare object, breaking the entire extension system.

Steps to Reproduce

  1. Have VS Code with multiple extensions installed on Windows
  2. Run install.ps1 (this deletes extensions.json)
  3. Restart VS Code — note that many extensions are now missing
  4. Run uninstall.ps1 — if only one extension remains registered, extensions.json is corrupted
  5. Restart VS Code — no extensions work, and no new extensions can be installed

Impact

  • All previously installed extensions are lost (folders deleted or unregistered)
  • extensions.json is corrupted so VS Code's extension system is completely broken
  • Users cannot install new extensions until the file is manually repaired

Suggested Fix

For install.ps1: Don't delete extensions.json. Instead, only remove the specific islands-dark entry (same approach as uninstall, but with the array fix below).

For uninstall.ps1: Force JSON array output regardless of element count:

# Option A: Wrap in array manually
"[$($extensions | ConvertTo-Json -Depth 10 -Compress)]" | Set-Content $extJsonPath

# Option B: Use -AsArray (PowerShell 7+ only)
$extensions | ConvertTo-Json -Depth 10 -Compress -AsArray | Set-Content $extJsonPath

Environment

  • Windows 11 Enterprise
  • VS Code 1.109.5
  • PowerShell (Windows built-in, 5.1)
  • #102 — Uninstalling removed all extensions
  • #111 — Overwrites all default user settings and removes all extensions
  • #86 — Windows installer is too invasive
Originally created by @khuynh22 on GitHub (Mar 4, 2026). Original GitHub issue: https://github.com/bwya77/vscode-dark-islands/issues/113 ## Description After installing via `install.ps1` and then uninstalling via `uninstall.ps1` on Windows, **all VS Code extensions are removed** and **no extensions can be installed or loaded**. VS Code reports: ``` Invalid extensions content in vscode-userdata:/c%3A/Users/<user>/.vscode/extensions/extensions.json ``` ## Root Cause There are two bugs — one in each script: ### Bug 1: `install.ps1` deletes `extensions.json` https://github.com/bwya77/vscode-dark-islands/blob/main/install.ps1#L49-L53 ```powershell $extJsonPath = "$env:USERPROFILE\.vscode\extensions\extensions.json" if (Test-Path $extJsonPath) { Remove-Item $extJsonPath -Force Write-Host "Cleared extensions.json (VS Code will rebuild it)" -ForegroundColor Green } ``` This deletes the extension registry outright. The comment says "previous versions of this script wrote invalid content to this file" — so the fix for the old bug was to just nuke the file. When VS Code rebuilds it, it only registers extensions it can discover on disk at startup, which may not include all previously installed extensions (e.g., extensions installed via marketplace that rely on proper metadata in this file). ### Bug 2: `uninstall.ps1` corrupts `extensions.json` via PowerShell serialization https://github.com/bwya77/vscode-dark-islands/blob/main/uninstall.ps1#L37-L45 ```powershell $extensions = @($extensions | Where-Object { $_.identifier.id -ne 'bwya77.islands-dark' -and $_.identifier.id -ne 'your-publisher-name.islands-dark' }) if ($extensions.Count -lt $before) { $extensions | ConvertTo-Json -Depth 10 -Compress | Set-Content $extJsonPath ``` When only **one extension** remains after filtering out `bwya77.islands-dark`, PowerShell's `ConvertTo-Json` serializes it as a **bare JSON object** `{...}` instead of a **JSON array** `[{...}]`. This is a well-known PowerShell 5.1 gotcha — the `@()` array wrapper does not survive `ConvertTo-Json` for single-element arrays. VS Code expects `extensions.json` to be a JSON array and cannot parse the bare object, breaking the entire extension system. ## Steps to Reproduce 1. Have VS Code with multiple extensions installed on Windows 2. Run `install.ps1` (this deletes `extensions.json`) 3. Restart VS Code — note that many extensions are now missing 4. Run `uninstall.ps1` — if only one extension remains registered, `extensions.json` is corrupted 5. Restart VS Code — **no extensions work, and no new extensions can be installed** ## Impact - All previously installed extensions are lost (folders deleted or unregistered) - `extensions.json` is corrupted so VS Code's extension system is completely broken - Users cannot install new extensions until the file is manually repaired ## Suggested Fix **For `install.ps1`:** Don't delete `extensions.json`. Instead, only remove the specific islands-dark entry (same approach as uninstall, but with the array fix below). **For `uninstall.ps1`:** Force JSON array output regardless of element count: ```powershell # Option A: Wrap in array manually "[$($extensions | ConvertTo-Json -Depth 10 -Compress)]" | Set-Content $extJsonPath # Option B: Use -AsArray (PowerShell 7+ only) $extensions | ConvertTo-Json -Depth 10 -Compress -AsArray | Set-Content $extJsonPath ``` ## Environment - Windows 11 Enterprise - VS Code 1.109.5 - PowerShell (Windows built-in, 5.1) ## Related Issues - #102 — Uninstalling removed all extensions - #111 — Overwrites all default user settings and removes all extensions - #86 — Windows installer is too invasive
Author
Owner

@oldjs commented on GitHub (Mar 9, 2026):

Unbelievable, this piece of junk made by your motherf develope just look at macOS users

<!-- gh-comment-id:4023237645 --> @oldjs commented on GitHub (Mar 9, 2026): Unbelievable, this piece of junk made by your motherf develope just look at macOS users
Author
Owner

@oldjs commented on GitHub (Mar 9, 2026):

I recommend using https://vsllm.com to recover.

<!-- gh-comment-id:4023240327 --> @oldjs commented on GitHub (Mar 9, 2026): I recommend using https://vsllm.com to recover.
Author
Owner

@YvonneSherwood5 commented on GitHub (Mar 10, 2026):

/Users/dingliangyi/Library/Application Support/Code/User/sync/extensions
See if it's possible to restore some plugins in this sync history
I have never seen such a shitty project.
I want to help some unfortunate people.

<!-- gh-comment-id:4032958473 --> @YvonneSherwood5 commented on GitHub (Mar 10, 2026): /Users/dingliangyi/Library/Application Support/Code/User/sync/extensions See if it's possible to restore some plugins in this sync history I have never seen such a shitty project. I want to help some unfortunate people.
Author
Owner

@hczs commented on GitHub (Mar 12, 2026):

Fuck!!!!!!!!!!

<!-- gh-comment-id:4043337048 --> @hczs commented on GitHub (Mar 12, 2026): Fuck!!!!!!!!!!
Author
Owner

@khuynh22 commented on GitHub (Mar 12, 2026):

Yeah the author wasn't even care about our comments

<!-- gh-comment-id:4044309087 --> @khuynh22 commented on GitHub (Mar 12, 2026): Yeah the author wasn't even care about our comments
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vscode-dark-islands#81
No description provided.