Skip to content

[Windows] Persistent Directory Corruption - Junction Loops & Reserved Names (nul file) #18432

@leonardleong

Description

@leonardleong

Description

Bug Description

OpenCode IDE on Windows creates corrupted directory structure that persists across reinstalls and portable installations:

  1. Junction loops: %USERPROFILE%, %APPDATA%, %LOCALAPPDATA% directories created inside OpenCode installation folder
  2. Windows reserved names: nul file keeps reappearing after deletion
  3. Permission corruption: takeown/icacls commands fail repeatedly due to process locks
  4. Corruption copies to portable installations during setup from backup

… - C:\Tools\OpenCode (Portable Mode - also corrupted)

Expected Behavior
Clean directory structure without:
Junction loops to system directories
Windows reserved names (nul, con, prn, aux, etc.)
Permission corruption preventing cleanup
Actual Behavior
Corrupted directory with:
C:\Users\Admin\AppData\Local\OpenCode
├── %USERPROFILE%/ ← Junction loop
├── %APPDATA%/ ← Junction loop
├── %LOCALAPPDATA%/ ← Junction loop
├── nul ← Windows reserved name
├── test.txt ← Corruption artifact
├── OpenCode.exe ← Main executable
└── opencode-cli.exe ← CLI tool
❌ Cannot uninstall cleanly
❌ Requires manual cleanup with PowerShell robocopy methods
❌ Corruption returns after reinstall
❌ Blocks Windows users from using OpenCode IDE
❌ Portable Mode workaround also affected (corruption copies from backup)
❌ Development work blocked until fixed
Workaround Attempted
Portable Mode Installation

Install to C:\Tools\OpenCode (outside AppData)

Use --user-data-dir=C:\Tools\OpenCode\Data

Result: Corruption copied from backup during installation

Cleanup Commands (Temporary Fix)

Kill processes

Get-Process | Where-Object {$_.Name -like "open"} | Stop-Process -Force

Remove junctions first

Remove-Item "OpenCode%USERPROFILE%" -Force -Recurse
Remove-Item "OpenCode%APPDATA%" -Force -Recurse
Remove-Item "OpenCode%LOCALAPPDATA%" -Force -Recurse

Then remove main directory

Remove-Item "C:\Users\Admin\AppData\Local\OpenCode" -Force -Recurse

Clear registry

Remove-Item "HKCU:\Software\OpenCode" -Recurse -Force
Note: Corruption returns after next OpenCode launch.
Request
✅ Avoid creating junction loops to system directories
✅ Release stable Windows build with proper path handling
✅ Provide official portable installation option
✅ Add corruption prevention checks on startup
Additional Context
Multiple recovery attempts
macOS/Linux builds appear stable (based on GitHub releases)
Windows build appears to be beta/unstable
Issue affects both AppData and Portable Mode installations
Specific to Windows 10 (Version 10.0.19045.6466)
System Information
Platform: win32
Architecture: x64
OS: Windows 10 (Version 10.0.19045.6466)
Node Version: v22.12.0
npm Version: 10.9.0
OpenCode Version: 1.2.27
Installation Type: Both AppData and Portable tried

Plugins

None

OpenCode version

1.2.27

Steps to reproduce

Steps to Reproduce

  1. Install OpenCode on Windows
    1. Run OpenCode IDE with any project
  2. Check installation directory for corrupted files:
    Get-ChildItem "C:\Users\Admin\AppData\Local\OpenCode" -Force
  3. Observe:
    Directories named %USERPROFILE%/, %APPDATA%/, %LOCALAPPDATA%/
    File named nul (Windows reserved name)
    File named test.txt (corruption artifact)
  4. Attempt to delete - fails with "directory busy" or permission errors
  5. Reinstall - corruption returns
  6. Portable Mode - corruption copies during installation from backup

Screenshot and/or share link

https://gyazo.com/579150eba73f87e8abd43444689324de

Image

https://gyazo.com/a2d6591a98b4d450ab1f2bd4c1b643a4

Image

Operating System

Windows 10 (Version 10.0.19045.6466)

Terminal

Windows Terminal cmd powershell bash

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions