Fix OpenCode Failing to Start When TEMP Points to a RAM Disk
Background
I needed to use OpenCode. I normally use ImDisk to put a temporary directory on a RAM disk. Every now and then, this causes minor compatibility problems.
The problem
After I launched the Scoop-installed version of OpenCode, it hung without printing anything. Pressing Ctrl+C did nothing either. When I installed it with npm or enabled logging, I could see the actual error:
INFO 2026-05-30T03:45:42 +127ms service=default worker shutting down
INFO 2026-05-30T03:45:42 +23ms service=file init
INFO 2026-05-30T03:45:42 +63ms service=db path=C:\Users\Floppy\.local\share\opencode\opencode.db opening database
INFO 2026-05-30T03:45:42 +7ms service=db count=20 mode=bundled applying migrations
INFO 2026-05-30T03:45:42 +27ms service=default disposing all instances
ERROR 2026-05-30T03:45:42 +463ms service=default name=Error message=Failed to initialize OpenTUI render library: Failed to open library "B:/~BUN/root/opentui-a7anrm45.dll": error code 126 stack=Error
at bD (B:/~BUN/root/chunk-9dg8905r.js:42:35988)
at c7 (B:/~BUN/root/chunk-9dg8905r.js:50:25234)
at <anonymous> (B:/~BUN/root/src/index.js:364:2399)
at processTicksAndRejections (unknown:7:39) fatal
Fix
In issue #3765, kommander suggested a workaround for this error.
The issue is caused by Bun. On Windows, setting the BUN_TMPDIR environment variable to a path on a regular disk fixes it.
This only changes where Bun puts its temporary files. Other applications can continue using the RAM disk for their own temporary files.