Description
When an environment variable is set with a native Windows path (backslashes), using{env:VAR}as a permission key causes opencode to fail with a JSON parse error on startup.
Plugins
No response
OpenCode version
1.14.33
Steps to reproduce
-
Set an environment variable with a native Windows path:
set MYDIR=C:\Users\me\AppData\Roaming\MyApp\config
-
Add it as a permission key in opencode.json:
"permission": {
"external_directory": {
"{env:MYDIR}/**": "allow"
}
}
-
Run opencode .
Expected behavior
opencode normalizes the expanded path to forward slashes before using it as a JSON key, or accepts backslashes in permission key paths on Windows.
Actual behavior
opencode expands {env:MYDIR} literally and treats the backslashes as JSON escape sequences, producing a parse error:
--- Errors ---
InvalidEscapeCharacter at line N, column 7
Line N: "C:\Users\me\AppData\Roaming\MyApp\config/**": "allow"
^
--- End ---
Workaround
Set the environment variable with forward slashes before launching opencode:
set MYDIR=C:/Users/me/AppData/Roaming/MyApp/config
This is not always possible when the variable is set by a third-party application that uses native Windows path separators.
Suggested fix
Normalize {env:...} expanded values to forward slashes before inserting them as permission key paths.
Screenshot and/or share link
No response
Operating System
Windows 11
Terminal
No response
Description
When an environment variable is set with a native Windows path (backslashes), using
{env:VAR}as a permission key causes opencode to fail with a JSON parse error on startup.Plugins
No response
OpenCode version
1.14.33
Steps to reproduce
Set an environment variable with a native Windows path:
set MYDIR=C:\Users\me\AppData\Roaming\MyApp\configAdd it as a permission key in opencode.json:
"permission": {
"external_directory": {
"{env:MYDIR}/**": "allow"
}
}
Run opencode .
Expected behavior
opencode normalizes the expanded path to forward slashes before using it as a JSON key, or accepts backslashes in permission key paths on Windows.
Actual behavior
opencode expands
{env:MYDIR}literally and treats the backslashes as JSON escape sequences, producing a parse error:Workaround
Set the environment variable with forward slashes before launching opencode:
set MYDIR=C:/Users/me/AppData/Roaming/MyApp/configThis is not always possible when the variable is set by a third-party application that uses native Windows path separators.
Suggested fix
Normalize
{env:...}expanded values to forward slashes before inserting them as permission key paths.Screenshot and/or share link
No response
Operating System
Windows 11
Terminal
No response