opencode
opencode copied to clipboard
[Windows 10] oh-my-opencode installation fails with EPERM: Operation not permitted (NtSetInformationFile())
Description
Bug Report: oh-my-opencode fails to install on Windows 10 due to EPERM error
Summary
Installing oh-my-opencode plugin on Windows 10 fails with an EPERM (Operation not permitted) error when Bun attempts to move the @ast-grep/cli-win32-x64-msvc package to the cache directory. This causes OpenCode to hang indefinitely during plugin loading.
Environment
System Information
- OS: Microsoft Windows 10 专业版
- Version: 10.0.19045 N/A Build 19045
- System Type: x64-based PC
- BIOS: American Megatrends International, LLC. 2.C0, 2021/2/1
Software Versions
- OpenCode: 1.1.12
- Bun: 1.3.5
- Node.js: v24.12.0
- oh-my-opencode: 2.14.0 (latest)
Security Settings
- Windows Defender Real-time protection: Disabled
- Administrator privileges: Tested, still fails
- Running from: Git Bash on Windows
Steps to Reproduce
- Create OpenCode config file:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["oh-my-opencode"]
}
- Run
opencodefrom the terminal - Observe that OpenCode hangs and never starts the TUI
Expected Behavior
- oh-my-opencode plugin should install successfully
- OpenCode should start normally with the plugin loaded
Actual Behavior
- OpenCode hangs indefinitely
- Plugin installation fails with EPERM error
Error Log
INFO 2026-01-10T18:34:16 +88ms service=default directory=C:\Users\24237\.config\opencode creating instance
INFO 2026-01-10T18:34:16 +0ms service=project directory=C:\Users\24237\.config\opencode fromDirectory
INFO 2026-01-10T18:34:16 +40ms service=default directory=C:\Users\24237\.config\opencode bootstrapping
INFO 2026-01-10T18:34:16 +4ms service=config path=C:\Users\24237\.config\opencode\config.json loading
INFO 2026-01-10T18:34:16 +1ms service=config path=C:\Users\24237\.config\opencode\opencode.json loading
INFO 2026-01-10T18:34:16 +7ms service=config path=C:\Users\24237\.config\opencode\opencode.jsonc loading
INFO 2026-01-10T18:34:16 +5ms service=config path=C:\Users\24237\.config\opencode\opencode.json loading
INFO 2026-01-10T18:34:16 +3ms service=bun cmd=["C:\\Users\\24237\\AppData\\Roaming\\npm\\node_modules\\opencode-ai\\node_modules\\opencode-windows-x64\\bin\\opencode.exe","add","@opencode-ai/[email protected]","--exact"] cwd=C:\Users\24237\.config\opencode running
INFO 2026-01-10T18:34:16 +23ms service=plugin name=CodexAuthPlugin loading internal plugin
INFO 2026-01-10T18:34:16 +0ms service=plugin path=oh-my-opencode loading plugin
INFO 2026-01-10T18:34:16 +1ms service=bun pkg=oh-my-opencode version=latest installing package using Bun's default registry resolution
INFO 2026-01-10T18:34:16 +0ms service=bun cmd=["C:\\Users\\24237\\AppData\\Roaming\\npm\\node_modules\\opencode-ai\\node_modules\\opencode-windows-x64\\bin\\opencode.exe","add","--force","--exact","--cwd","C:\\Users\\24237\\.cache\\opencode","oh-my-opencode@latest"] cwd=C:\Users\24237\.cache\opencode running
INFO 2026-01-10T18:34:16 +31ms service=bun code=0 stdout=bun add v1.3.5 (1e86cebd)
installed @opencode-ai/[email protected]
[15.00ms] done
stderr=Saved lockfile
done
INFO 2026-01-10T18:34:16 +0ms service=bun cmd=["C:\\Users\\24237\\AppData\\Roaming\\npm\\node_modules\\opencode-ai\\node_modules\\opencode-windows-x64\\bin\\opencode.exe","install"] cwd=C:\Users\24237\.config\opencode running
INFO 2026-01-10T18:34:16 +46ms service=bun code=0 stdout=bun install v1.3.5 (1e86cebd)
Checked 3 installs across 4 packages (no changes) [8.00ms]
stderr= done
INFO 2026-01-10T18:34:19 +2519ms service=bun code=1 stdout=bun add v1.3.5 (1e86cebd)
stderr=[2.16ms] migrated lockfile from package-lock.json
Resolving dependencies
Resolved, downloaded and extracted [1]
error: moving "@ast-grep/cli-win32-x64-msvc" to cache dir failed
EPERM: Operation not permitted (NtSetInformationFile())
From: .3cfdfb7be63bebb7-00000001.cli-win32-x64-msvc
To: @ast-grep/[email protected]@@@1
error: InstallFailed extracting tarball from @ast-grep/cli-win32-x64-msvc
done
ERROR 2026-01-10T18:34:19 +1ms service=default e=BunInstallFailedError exception
Additional Information
Binary File Status
The @ast-grep/cli-win32-x64-msvc binary file exists and has correct permissions:
-rwxr-xr-x 3 24237 197609 45M Jan 11 01:39 ~/.cache/opencode/node_modules/@ast-grep/cli-win32-x64-msvc/ast-grep.exe
Working Directory
- Bun cache:
C:\Users\24237\.bun\install\cache - OpenCode cache:
C:\Users\24237\.cache\opencode - Config:
C:\Users\24237\.config\opencode
Attempted Workarounds
- Disabled Windows Defender Real-time Protection - No effect
- Run as Administrator - No effect (tested via PowerShell)
-
Use alternative cache directory with
--cache-dir- No effect - Try different oh-my-opencode versions (2.13.2, 3.0.0-beta.2) - Same error
- Use npm instead of bun for manual installation - Installs successfully but runtime fails
Bun's NtSetInformationFile() Issue
The error occurs when Bun calls NtSetInformationFile() to move the extracted package from a temporary location to the cache directory. This appears to be a known issue with Bun on Windows when handling large binary packages.
Possible Root Causes
- File handle not properly closed: The extracted binary file may not be fully closed before Bun attempts to move it
- Anti-virus interference: Despite disabling Windows Defender, other security software may be interfering
-
Bun's Windows file system implementation: Bun may have issues with
NtSetInformationFile()on Windows 10 - File locking by another process: Another process (possibly Git Bash) may be holding a lock on the file
Suggested Solutions
- Add Windows-specific installation logic in oh-my-opencode to handle the binary package installation manually
- Use npm instead of bun for installing dependencies on Windows (if supported by OpenCode)
- Pre-compile ast-grep for Windows to avoid runtime installation
- Add a retry mechanism in OpenCode's plugin installer to handle transient EPERM errors
- Improve error reporting to provide actionable guidance to users (e.g., "Try running as administrator" or "Try installing via WSL")
Workarounds
Users experiencing this issue can work around it by:
- Installing OpenCode and oh-my-opencode in WSL (Windows Subsystem for Linux)
- Using Docker or a virtual machine to run Linux-based development environment
References
- Related issue: https://github.com/code-yeongyu/oh-my-opencode/issues
- Bun Windows file system discussion
- Windows NtSetInformationFile() documentation