Repository navigation
Description
Summary
On macOS, OpenCode v2.0.19 requests external_directory permission for a literal /var/folders/<id>/<id>/T/opencode/... path, even though this is the /var alias of OpenCode's managed temporary directory.
The effective permission rules include a built-in allow rule for the realpath spelling /private/var/folders/<id>/<id>/T/opencode/*. The shell permission parser passes the literal /var/... directory from cd to authorization, and the boundary check compares it lexically without resolving it to its realpath. Therefore, the built-in allow rule does not match.
Environment
- opencode version: 2.0.19
- OS: macOS (Darwin, arm64)
- Terminal: iTerm.app (
TERM=xterm-256color,COLORTERM=truecolor) - Shell:
/bin/zsh - Install/channel: installed release 2.0.19; npm latest is 2.0.20
- Active plugins: A configured plugin is present but does not handle permission evaluation.
Reproduction
- On macOS, start OpenCode v2.0.19 in a clean project with no saved permission approvals.
- Use a literal path under the macOS temporary-directory alias:
/var/folders/<id>/<id>/T/opencode/probe - Have the agent invoke the
shelltool with:mkdir -p /var/folders/<id>/<id>/T/opencode/probe && cd /var/folders/<id>/<id>/T/opencode/probe && pwd
- Observe the permission request.
Expected Behavior
No external_directory confirmation should be requested.
The permissions documentation states: "OpenCode also allows external-directory access to its managed tool-output, shell-output, temporary, and global configuration directories." The literal /var/folders/<id>/<id>/T/opencode/... path refers to the same macOS location as the built-in allowed realpath:
/private/var/folders/<id>/<id>/T/opencode/*
Actual Behavior
OpenCode requests external_directory permission for:
/var/folders/<id>/<id>/T/opencode/probe/*
This was also observed with a user-rejected request for:
cd /var/folders/<id>/<id>/T/opencode/<dir> && git status --shortIn v2.0.19, the shell parser extracts literal directories from directory-changing commands such as cd. It does not resolve $TMPDIR during permission analysis: commands containing that shell expression are not a valid reproduction of this issue.
Additional Context
The built-in allow rule uses the realpath spelling:
/private/var/folders/<id>/<id>/T/opencode/*
Inspection of v2.0.19 indicates that FileAccess.resolve / authorizeExternal performs the relevant boundary comparison lexically, without canonicalizing the supplied /var/... path first. As a result, the equivalent macOS aliases do not match.
A workaround is to add an explicit allow rule for the /var spelling:
{
"action": "external_directory",
"resource": "/var/folders/*/*/T/opencode/*",
"effect": "allow"
}With that rule, the reproduction command no longer requests permission.
The relevant agent.ts, file-access.ts, shell/parse.ts, and global.ts files did not change between v2.0.19 and v2.0.20, so this behavior is likely still present in v2.0.20.
Related
- [FEATURE]: Provide a default pre-approved temp directory for skills/tools writing outside the workspace #48100 is a feature request for a portable, documented pre-approved temporary directory. This report concerns a matching failure for OpenCode's already managed
opencodetemporary directory. - Interactive TUI hangs in macOS temp directories due to /var vs /private/var path split #16607 is a closed report of the same macOS
/varversus/private/varalias split, but with a different interactive-TUI symptom. - PR fix(core): resolve symlinks before the external_directory boundary check #52224 changes
packages/core/src/file-access.tsto resolve real paths before theexternal_directoryboundary check. It is directly relevant and may also resolve this alias mismatch; it is currently open and is described as fixing related lexical-versus-realpath behavior for symlinks.
Activity
github-actions commentedon Sep 30, 2026
This issue might be a duplicate of an existing issue. Please check:
external_directoryprompts when canonical project paths and symlink-spelled tool paths do not match.opencodejr commentedon Oct 28, 2026
Thanks for the detailed report. I reproduced this on 2.0.19. On Linux I pointed
TMPDIRat a symlink to fake macOS's/var→/private/varalias. A shellcdinto the realpath spelling of OpenCode's managed temp directory ran without a prompt. The samecdthrough the symlinked spelling asked forexternal_directorypermission (pattern…/opencode/probe-alias/*), just as you describe.On the latest
dev(f0160a1) this no longer happens. #53585 ("stop asking for external directory access by default") removed the defaultexternal_directory: askrule, so with default permissions the/var/folders/...alias is allowed and there's no prompt. I checked this by evaluating the default agent's permission rules ondev, not by re-running the TUI script. The latest release, 2.2.0, also no longer has theaskdefault, so upgrading should get rid of the prompt.One caveat: the external-directory check still compares paths as plain text, without resolving symlinks. If you set
external_directorytoaskyourself, alias spellings can still behave differently. Related:external_directorycheckexternal_directorycheckThe bot will close this issue in 1 day unless you reply that it still happens, e.g. on 2.2.0 or newer.
opencodejr commentedon Oct 29, 2026
Closing this as completed, since there's been no reply in the day since my last comment. I reproduced the prompt for the
/var/...alias of the managed temp directory on 2.0.19. On the latestdevit no longer happens: #53585 stopped asking forexternal_directoryaccess by default. 2.2.0 doesn't have theaskdefault either, so upgrading should get rid of the prompt.If it still happens on 2.2.0 or newer, please comment here or open a new issue with your version and permission config. Separately, the plain-text path comparison when
external_directoryis set toaskis tracked in #52224 and #58638. Thanks again for the thorough report!