Skip to content

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

Closed as not planned

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

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 20, 2026
  2. github-actions commented on Mar 20, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    The junction loop portion (%USERPROFILE%, %APPDATA%, %LOCALAPPDATA% directories being created inside the installation folder) may be unique to this report. If the nul file aspect is already covered by the above, please consider whether this issue should focus specifically on the junction loop behavior.

  3. leonardleong commented on Mar 20, 2026

    @leonardleong
    Author

    Additional Context: Junction Loop Behavior

    Thank you for identifying the related nul file issues. I want to highlight that my report includes an additional corruption pattern that may be unique:

    Junction Loop Directories Created Inside OpenCode Installation

    C:\Users\Admin\AppData\Local\OpenCode
    ├── %USERPROFILE%/ ← Junction/symlink loop
    ├── %APPDATA%/ ← Junction/symlink loop
    │ └── OpenCode/ ← Nested loop!
    ├── %LOCALAPPDATA%/ ← Junction/symlink loop
    │ └── OpenCode/ ← Nested loop!
    ├── nul ← Windows reserved name (matches #13369)
    └── test.txt ← Unknown artifact

    Why This Matters

    1. Infinite directory traversal - Any tool scanning the folder gets stuck in loops
    2. Prevents clean uninstall - Directory appears "busy" even after killing all processes
    3. Corruption copies to Portable Mode - When backing up before reinstall, junctions are copied
    4. Different from pure nul file issues - Related issues (Undeletable nul file #13369, Unexpected file named "nul" is repeatedly created after updating OpenCode #11403, nul file generate #11586) focus on nul file only

    Request

    …- npm: 10.9.0

  4. leonardleong commented on Mar 20, 2026

    @leonardleong
    Author

    Additional Context: Junction Loop Behavior (Potentially Unique)
    Thank you for identifying the related nul file issues (#13369, #11403, #11586). I want to highlight that my report includes an additional corruption pattern that may be unique to my installation or affect a subset of Windows users.
    🔍 Junction Loop Directories Created Inside OpenCode Installation
    After multiple recovery attempts and Portable Mode installation, I observed the following directory structure being created at runtime inside the OpenCode installation folder:
    C:\Users\Admin\AppData\Local\OpenCode
    ├── %USERPROFILE%/ ← Junction/symlink loop
    │ └── Admin/
    │ └── AppData/
    │ └── Local/
    │ └── OpenCode/ ← INFINITE LOOP!
    ├── %APPDATA%/ ← Junction/symlink loop
    │ └── Roaming/
    │ └── OpenCode/ ← Nested loop!
    ├── %LOCALAPPDATA%/ ← Junction/symlink loop
    │ └── Local/
    │ └── OpenCode/ ← Nested loop!
    ├── nul ← Windows reserved name (matches #13369)
    ├── test.txt ← Unknown artifact
    ├── OpenCode.exe ← Main executable
    └── opencode-cli.exe ← CLI tool
    🛠️ Technical Evidence
    Verification Commands:

    Check for junction loops

    Get-ChildItem "C:\Users\Admin\AppData\Local\OpenCode" -Filter "%" -Force |
    Select-Object Name, Mode, Target

    Check reparse point attributes

    fsutil reparsepoint query "C:\Users\Admin\AppData\Local\OpenCode%USERPROFILE%"

    Check directory attributes

    (Get-Item "C:\Users\Admin\AppData\Local\OpenCode%USERPROFILE%").Attributes

    Attempt deletion (fails with "directory busy")

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

    https://gyazo.com/b3a488d23b3986f9bb0472cba75073ed

    Image

    https://gyazo.com/c840081a158ee96574a11a224764ba71

    Image

    🔬 Root Cause Hypothesis

    Windows expands these at filesystem level instead of application level
    Junction points are created pointing back to parent directories
    Self-referential loops form when OpenCode is installed in AppData
    Corruption persists because junctions survive process termination

    📝 Reproduction Steps (Specific to Junction Loops)

    1. Install OpenCode to AppData

    Default installation via OpenCode-Setup-latest.exe

    2. Run OpenCode IDE

    Open any project (e.g., C:\Users\Admin\openclaw)

    3. Use OpenCode for normal development

    Edit files, use AI features, etc.

    4. Close OpenCode

    Exit application normally

    5. Check installation directory

    Get-ChildItem "C:\Users\Admin\AppData\Local\OpenCode" -Force

    6. Observe junction loops

    %USERPROFILE%/, %APPDATA%/, %LOCALAPPDATA%/ directories present

    7. Attempt cleanup

    Standard deletion fails, requires robocopy method

  5. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  6. github-actions commented on Jul 4, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions