anomalyco / anomalyco/opencode
cli: no way to refresh environment variables without restarting
Open
@Hona is already working on this.
Since Sep 14, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Summary
After modifying system/user environment variables (e.g., adding a new directory to PATH), OpenCode does not detect the changes until a full restart. There is no built-in way to refresh environment variables within a running session.
Environment
- opencode version: 2.0.3
- OS: Windows_NT 10.0.26200 (win32 x64)
- Shell: Git Bash (MINGW64)
Reproduction
- Install a CLI tool to a new directory (e.g.,
D:\Tools\gh\bin\) - Add the directory to the user PATH via system settings
- In an active OpenCode session, try to use the tool:
gh --version - Command not found — the new PATH is not reflected
Expected Behavior
OpenCode should either:
- Re-read environment variables on demand (e.g., a
refresh-envcommand or API) - Or detect PATH changes and update the shell environment automatically
Actual Behavior
The only workaround is to fully restart OpenCode. All running sessions, context, and state are lost.
Additional Context
This affects any workflow where tools are installed or environment variables are modified mid-session. Common scenarios:
- Installing new CLI tools (gh, docker, etc.) via package managers
- Modifying proxy settings (
HTTP_PROXY,NO_PROXY) - Switching Node.js versions via nvm
- Updating API keys or tokens stored in env vars
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.