GeezerVison is showing github.com — Windows: OpenCode 2.3.0 ignores customized `TEMP`/`TMP` and uses `C:\Users\<user>\AppData\Local\Temp\opencode` instead of `%TEMP%\opencode` · Issue #64019 · anomalyco/opencode
Windows: OpenCode 2.3.0 ignores customized TEMP/TMP and uses C:\Users\<user>\AppData\Local\Temp\opencode instead of %TEMP%\opencode #64019DescriptionDescription
Description
On Windows, OpenCode 2.3.0 appears to ignore a customized TEMP/TMP environment variable when choosing its temporary directory.
In previous versions, OpenCode used %TEMP%\opencode (i.e. it respected the current TEMP value). In 2.3.0, it seems to always use the default user temp path:
C:\Users\<username>\AppData\Local\Temp\opencode
even when TEMP and TMP have been changed to another location (for example D:\Temp).
This means the temporary files are written to the system default user temp directory instead of the directory configured through the environment variables.
Environment
- OpenCode version: 2.3.0
- OS: Windows 10/11 (please fill in exact version)
- Installation method: (e.g. desktop app / CLI / npm / standalone — please fill in)
- Shell used to launch OpenCode: (e.g. PowerShell / CMD / Windows Terminal — please fill in)
Expected behavior
OpenCode should use %TEMP%\opencode / %TMP%\opencode, i.e. it should respect the current TEMP/TMP environment variables, as previous versions did.
Alternatively, if there is a reason not to inherit them, there should be a documented configuration option or environment variable to override the temp directory.
Actual behavior
OpenCode creates/uses:
C:\Users\<username>\AppData\Local\Temp\opencode
even when TEMP and TMP point to a different directory.
Additional context
- This looks related to the existing reports about OpenCode not respecting
TMPDIR/TEMP/TMP on Windows and about the bundled Bun runtime’s temp-directory handling.
- I have not yet confirmed whether setting
BUN_TMPDIR changes the behavior, but the regression compared with previous versions seems to be in how OpenCode resolves its temp root on Windows.
- Please let me know if you need logs, a trace, or a minimal reproduction repository.
Plugins
It most likely has nothing to do with any plugin, because this just looks like an issue with system prompt injection.
OpenCode version
2.3.0
Steps to reproduce
- On Windows, change the user/system
TEMP and TMP environment variables to a custom directory, e.g. D:\Temp.
- Open a new terminal and verify the variables are inherited:
echo $env:TEMP
echo $env:TMP
Both should print the custom path.
- Start OpenCode 2.3.0 from that terminal.
- Trigger any operation that creates OpenCode temporary files.
- Check where the
opencode temp directory is created.
Screenshot
No response
Operating System
windows 11
Terminal
PowerShell Activityopencodejr commented on Nov 15, 2026 Thanks for the report. Before we try to reproduce it, a few details would help.
OpenCode builds its temp folder from the system temp directory plus opencode (path.join(os.tmpdir(), app) in packages/util/src/global-roots.ts). As far as I can see, that code is the same in 2.2.7 and 2.3.0. The path you see (for example in the agent's environment instructions) comes from the shared background service, which OpenCode normally finds or starts automatically (troubleshooting docs). My guess, which I haven't confirmed: if that service started before you changed TEMP/TMP, or something other than your terminal started it, it could still be using the default AppData\Local\Temp.
Could you tell us:
- How you installed and launch OpenCode: the Desktop app, or the CLI (npm
@opencode/cli, install script, other)? The template placeholders for this were left unfilled.
- What
opencode --version prints, and which earlier version you saw using D:\Temp\opencode.
- Whether a service restart changes it. In a PowerShell where
echo $env:TEMP prints your custom path, run opencode service restart, start OpenCode again from that shell, and check which folder it uses.
- Where you saw the path: the agent's environment instructions, a file actually created on disk, or both? If it's a file, which operation created it?
You can reply here with the details or edit the issue. If you edit it, please also leave a comment saying you've updated it, so we know when you're done.
Related issues I found, ordered by likelihood. None of them looks like the same problem:
opencodejr commented on Nov 15, 2026 We haven't heard back here, so I'm closing this issue for now.
We were waiting for a few details:
- how OpenCode is installed and launched (Desktop or CLI)
- the exact
opencode --version and the last version that used D:\Temp\opencode
- whether running
opencode service restart from a shell where $env:TEMP shows your custom path changes the folder
- where you saw the path
Without these, we can't tell a 2.3.0 regression apart from a background service that started with older environment variables.
If you can still reproduce this, reply here with those details and the issue will reopen.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|