Repository navigation
.env file in project directory triggers Bun ThreadLock panic on Windows (TUI crash) #15015
Description
Description
Description
OpenCode TUI crashes immediately on startup with Bun ThreadLock assertion failure when the project directory contains .env files. Removing all .env* files allows OpenCode to
start normally.
Environment
- OpenCode: 1.2.11
- Bun: Canary v1.3.10-canary.100 (6b1d6c76) Windows x64 (baseline)
- OS: Windows 11 Pro 10.0.26200
- Terminal: PowerShell
Plugins
No response
OpenCode version
1.2.11
Steps to reproduce
Steps to Reproduce
- Create a project directory with
git init - Add a
.envfile with any content, e.g.:
VITE_PORT = 8848
VITE_HIDE_HOME = false - Run
opencode - Observe crash
Expected Behavior
OpenCode TUI starts normally.
Actual Behavior
Bun panics with ThreadLock assertion failure:
panic(thread 31580): Internal assertion failure: ThreadLock is locked by thread 31104, not thread 31580
oh no: Bun has crashed. This indicates a bug in Bun, not your code.
Debugging Details
Through binary search isolation, I confirmed:
| Condition | Result |
|---|---|
| Empty directory (with git) | ✅ Works |
Project files without .env |
✅ Works |
Same project files + .env |
❌ Crash |
Only .env file added |
❌ Crash |
opencode --helpandopencode run "hello"work fine — crash is TUI-specificopencode --versionreturns1.2.11correctly- Crash occurs after config loading, during TUI initialization
- The
.envcontent doesn't matter — even a minimal.envtriggers the crash - Attempted
BUN_CONFIG_NO_DOTENV=1andBUN_ENV_FILE=""— neither prevents the crash (Bun loads.envbefore processing env vars)
Crash Report URL
https://bun.report/1.3.10/ea26b1d6c7kWugogC+iwgN+xxuK4t2wMuqoNkxvNm9mQwwn0eCYKERNEL32.DLLut0LCSntdll.dll4gijBA0eNrzzCtJLcpLzFFILC5OLSrJzM9TSEvMzCktSrVSSAjJKEpNTPHJT85OUMgsVsjJT85OTV
FIqlQoAUsoGBsaGpjoKOTll8BEjA1NLQwAGbocyQ
Workaround
Temporarily rename .env* files before launching OpenCode:
# PowerShell workaround
$envFiles = Get-ChildItem -Filter ".env*" -File -ErrorAction SilentlyContinue
foreach ($f in $envFiles) { Rename-Item $f.FullName "$($f.FullName).__bak" }
try { opencode @args }
finally { foreach ($f in $envFiles) { $bak = "$($f.FullName).__bak"; if (Test-Path $bak) { Rename-Item $bak $f.FullName } } }
Suggestion
Consider passing --env-file "" to the embedded Bun runtime to disable automatic .env loading, or upgrade to a Bun version that fixes the ThreadLock race condition on Windows.
### Screenshot and/or share link
_No response_
### Operating System
_No response_
### Terminal
_No response_
Activity
github-actions commentedon Feb 25, 2026
This issue might be a duplicate of existing issues. Please check:
roymasad commentedon Feb 25, 2026
Same problem here also, after upgrading opencode tui to 1.2.12 it crashes if i open it in a project with an env file
ricred commentedon Feb 25, 2026
still same error here using opencode tui 1.2.13
ramhaidar commentedon Feb 25, 2026
Opencode TUI 1.2.13 Still Same Error
abakumov-v commentedon Feb 25, 2026
same error on Windows 11 + I have bun 1.2.15 installed, but looks like opencode uses it's own bun instance taken from
node_modulesjust happened today accidentially - probably, after auto-updating to 1.2.14 because in the morning it was 1.2.10 (or 1.2.12) and it worked fine
abakumov-v commentedon Feb 25, 2026
ha, this works fine:
1/ disable auto updates
2/ run this:
you even don't need to clean
~/.config/opencode/node_modulesRahullkumr commentedon Feb 25, 2026
but @abakumov-v how to disable auto updates?
Tantless commentedon Feb 26, 2026
@Rahullkumr try add
"autoupdate": falsein ur~/.config/opencode/opencode.jsonHona commentedon Feb 26, 2026
please upgrade to latest OpenCode v1.2.15 - and try again.
There should be no more segfaults/crashes.
Can you confirm it works fine after the version is >v1.2.15 :)
ramhaidar commentedon Feb 26, 2026
@Hona confirmed its working now, no more sefgaults/crashes!