Repository navigation
Description
Description
When opencode serve is launched from a directory like /workspace (as a non‑root user), the server incorrectly sets its workspace or working directory to root / instead of the current working directory. This leads to two problems:
Problem 1: Base directory/Working Directory ignored – The browser interface shows the entire filesystem, and projects can be opened from anywhere (/tmp, /etc, etc.), disregarding the intended working directory.
Problem 2: Permission path mismatches – When opening a project at /workspace and confirming via shell that current working directory is /workspace, editing a file inside an opened project (e.g., /workspace/projects/project6/test.py) produces wrong behaviour - the permission system evaluates a malformed relative path (workspace/projects/project6/test.py without the root forward slash, neither using absolute path, nor the correct relative path relative to working directory or path of the opened project) that does not match absolute allow‑rules like /workspace/projects/**. Consequently, edits are incorrectly denied.
logs
[opencode-host] | + /usr/local/bin/startup.sh:919: pwd
[opencode-host] | /workspace
[opencode-host] | + /usr/local/bin/startup.sh:920: cd /workspace
[opencode-host] | + /usr/local/bin/startup.sh:921: pwd
[opencode-host] | /workspace
[opencode-host] | + /usr/local/bin/startup.sh:923: exec opencode serve --log-level DEBUG --hostname 0.0.0.0 --port 8080
[opencode-host] | Warning: OPENCODE_SERVER_PASSWORD is not set; server is unsecured.
[opencode-host] | opencode server listening on http://0.0.0.0:8080
INFO 2026-02-20T13:13:46 +201ms service=default version=1.2.9 args=["serve","--log-level","DEBUG","--hostname","0.0.0.0","--port","8080"] opencode
INFO 2026-02-20T13:13:46 +2ms service=config path=/home/opencode/.config/opencode/config.json loading
INFO 2026-02-20T13:13:46 +2ms service=config path=/home/opencode/.config/opencode/opencode.json loading
INFO 2026-02-20T13:13:46 +0ms service=config path=/home/opencode/.config/opencode/opencode.jsonc loading
INFO 2026-02-20T13:13:47 +275ms service=server method=GET path=/global/health request
INFO 2026-02-20T13:13:47 +0ms service=server status=started method=GET path=/global/health request
INFO 2026-02-20T13:13:47 +0ms service=server status=completed duration=0 method=GET path=/global/health request
INFO 2026-02-20T13:13:48 +945ms service=server method=GET path=/global/health request
INFO 2026-02-20T13:13:48 +0ms service=server status=started method=GET path=/global/health request
INFO 2026-02-20T13:13:48 +0ms service=server status=completed duration=0 method=GET path=/global/health request
INFO 2026-02-20T13:13:51 +3446ms service=server method=GET path=/global/event request
INFO 2026-02-20T13:13:51 +0ms service=server status=started method=GET path=/global/event request
INFO 2026-02-20T13:13:51 +1ms service=server global event connected
INFO 2026-02-20T13:13:51 +2ms service=server status=completed duration=3 method=GET path=/global/event request
INFO 2026-02-20T13:13:51 +32ms service=server method=GET path=/global/health request
INFO 2026-02-20T13:13:51 +0ms service=server status=started method=GET path=/global/health request
INFO 2026-02-20T13:13:51 +0ms service=server status=completed duration=0 method=GET path=/global/health request
INFO 2026-02-20T13:13:51 +8ms service=server method=GET path=/path request
INFO 2026-02-20T13:13:51 +1ms service=server status=started method=GET path=/path request
INFO 2026-02-20T13:13:51 +0ms service=default directory=/workspace creating instance
INFO 2026-02-20T13:13:51 +0ms service=project directory=/workspace fromDirectory
...
INFO 2026-02-20T13:19:54 +634ms service=permission permission=edit pattern=workspace/projects/project6/test.py ruleset=[{"permission":"*","pattern":"*","action":"allow"},{"permission":"doom_loop","pattern":"*","action":"ask"},{"permission":"external_directory","pattern":"*","action":"ask"},{"permission":"external_directory","pattern":"/home/opencode/.local/share/opencode/tool-output/*","action":"allow"},{"permission":"question","pattern":"*","action":"deny"},{"permission":"plan_enter","pattern":"*","action":"deny"},{"permission":"plan_exit","pattern":"*","action":"deny"},{"permission":"read","pattern":"*","action":"allow"},{"permission":"read","pattern":"*.env","action":"ask"},{"permission":"read","pattern":"*.env.*","action":"ask"},{"permission":"read","pattern":"*.env.example","action":"allow"},{"permission":"question","pattern":"*","action":"allow"},{"permission":"plan_enter","pattern":"*","action":"allow"},{"permission":"*","pattern":"*","action":"ask"},{"permission":"edit","pattern":"*","action":"deny"},{"permission":"edit","pattern":"**","action":"deny"},{"permission":"edit","pattern":"/workspace/templates/**","action":"deny"},{"permission":"edit","pattern":"/workspace/projects/**","action":"ask"},{"permission":"write","pattern":"*","action":"deny"},{"permission":"write","pattern":"**","action":"deny"},{"permission":"write","pattern":"/workspace/templates/**","action":"deny"},{"permission":"write","pattern":"/workspace/projects/**","action":"ask"},{"permission":"patch","pattern":"*","action":"deny"},{"permission":"patch","pattern":"**","action":"deny"},{"permission":"patch","pattern":"/workspace/templates/**","action":"deny"},{"permission":"patch","pattern":"/workspace/projects/**","action":"ask"},{"permission":"multiedit","pattern":"*","action":"deny"},{"permission":"multiedit","pattern":"**","action":"deny"},{"permission":"multiedit","pattern":"/workspace/templates/**","action":"deny"},{"permission":"multiedit","pattern":"/workspace/projects/**","action":"ask"},{"permission":"read","pattern":"*","action":"ask"},{"permission":"grep","pattern":"*","action":"ask"},{"permission":"glob","pattern":"*","action":"ask"},{"permission":"list","pattern":"*","action":"deny"},{"permission":"list","pattern":"/workspace/templates/**","action":"ask"},{"permission":"list","pattern":"/workspace/projects/**","action":"ask"},{"permission":"bash","pattern":"*","action":"ask"},{"permission":"lsp","pattern":"*","action":"deny"},{"permission":"task","pattern":"*","action":"ask"},{"permission":"skill","pattern":"*","action":"ask"},{"permission":"todowrite","pattern":"*","action":"ask"},{"permission":"todoread","pattern":"*","action":"ask"},{"permission":"webfetch","pattern":"*","action":"ask"},{"permission":"websearch","pattern":"*","action":"ask"},{"permission":"codesearch","pattern":"*","action":"ask"},{"permission":"question","pattern":"*","action":"allow"},{"permission":"doom_loop","pattern":"*","action":"ask"},{"permission":"external_directory","pattern":"/home/opencode/.local/share/opencode/tool-output/*","action":"allow"}] evaluate
INFO 2026-02-20T13:19:54 +0ms service=permission permission=edit pattern=workspace/projects/project6/test.py action={"permission":"edit","pattern":"**","action":"deny"} evaluated
Plugins
N/A
OpenCode version
[email protected] (npm)
Steps to reproduce
-
As a non‑root user, create a project structure:
mkdir -p /workspace/projects/project6 -
Start the server from /workspace:
cd /workspace
opencode serve --log-level DEBUG --hostname 0.0.0.0 --port 8080 -
Open the server in a browser (e.g., http://localhost:8080).
Observe: The file browser shows the root /, not /workspace. -
Open the project at /workspace via the UI.
-
ask any llm to write/edit print("Hello World!") to /workspace/projects/project6/test.py.
Screenshot and/or share link
No response
Operating System
Debian 12 Bookworm
Terminal
Windows Terminal
Activity
gitrequests commentedon Mar 22, 2026
Related issue: #14656
typoworx-de commentedon Apr 17, 2026
I can confirm the issue as I also was wondering how this could happen.
Vinayaka-Hebbar commentedon Jun 26, 2026
any solution for this issue.
opencode webnot opening in cwdszymor commentedon Jul 14, 2026
Run
opencode servein a git repository as a workaround.I reported the issue with root cause analysis: #36858
github-actions commentedon Sep 14, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.
Pereitor commentedon Sep 27, 2026
How is it possible that such a critical bug is closed without a fix? "Not planned"?? Really? This causes the agent to have access to the WHOLE filesystem! I just realized while inspecting the and got shocked to find out the the "Workspace root folder" is /!!!
OMG, have the team even taken a look at what this bug means??
szymor commentedon Sep 27, 2026
I think this is rather a UI misunderstanding thing. The path is properly determined if your working directory is a git repository.
The behaviour also differs between the desktop and the headless variants.
I think the dev team cannot reproduce the thing, because they are accustomed to a certain use case.
Pereitor commentedon Sep 27, 2026
I have no idea what the different behaviour amongst versions is. I'm using the Linux CLI version through WSL. In any case, the severity of this bug is clear to me, and the potential effects are very serious. You are exposing the whole filesystem to the agent!! Also the fix is so trivial that it makes it absolutely unbelievable they don't address it.