You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For projects whose folder exists but isn't a git repository, the service logs a WARN on most requests. The error name says the directory is unavailable, but it exists.
~/.local/share/opencode/log/opencode.log has 641 of these since 2026-10-05: 531 for one non-git project, 109 for another, and 1 for the home folder. All three folders exist.
Expected
Skip git discovery for non-git projects, or log it once at debug level with an accurate message such as "not a git repository".
Thanks for the clear report. I could reproduce this on 2.1.2, and it still happens on the latest dev (248bfbe).
Steps: start opencode serve inside a folder that exists but isn't a git repository, open that folder as a project, then call the worktree refresh endpoint (POST /api/worktree/refresh). Each refresh adds one line to opencode.log:
The script below reproduces it. In the code, the git worktree strategy reports "directory unavailable" whenever it finds no git repository, even though the folder exists, and the refresh logs that as a warning every time. So the count in your log grows with how often the app refreshes worktrees for those projects. I've passed this to the maintainers along with the details.
Reproduction script (repro.sh)
#!/usr/bin/env bash
# Reproduces #57989: WARN "worktree discovery failed ... Worktree.DirectoryUnavailableError"
# for an existing, non-git project directory on every worktree refresh.
# Usage: OPENCODE="opencode" bash repro.sh (or OPENCODE="bun ... packages/cli/src/index.ts")
set -u
OPENCODE=${OPENCODE:-opencode}
PORT=${PORT:-4517}
export HOME=$(mktemp -d /tmp/opencode/home.XXXX)
export XDG_DATA_HOME=$HOME/.local/share XDG_CONFIG_HOME=$HOME/.config XDG_STATE_HOME=$HOME/.local/state XDG_CACHE_HOME=$HOME/.cache
PROJ=$HOME/work/plain-folder; mkdir -p "$PROJ"; echo hi > "$PROJ/readme.txt" # exists, not a git repo
cd "$PROJ"
$OPENCODE --version
$OPENCODE serve --port $PORT --hostname 127.0.0.1 > $HOME/serve.out 2>&1 &
SRV=$!; trap 'kill $SRV 2>/dev/null' EXIT
for i in $(seq 60); do grep -q "server password" $HOME/serve.out 2>/dev/null && break; sleep 0.5; done
B=http://127.0.0.1:$PORT
PW=$(sed -n "s/^server password //p" $HOME/serve.out); C="curl -s -u opencode:$PW"
echo "== location.get for $PROJ"
$C -G "$B/api/location" --data-urlencode "location[directory]=$PROJ"; echo
PID=$($C "$B/api/project" | python3 -c 'import json,sys;d=json.load(sys.stdin);d=d if isinstance(d,list) else d.get("data",d);print([p for p in d if "plain-folder" in json.dumps(p)][0]["id"])')
echo "projectID=$PID"
for i in 1 2 3; do $C -o /dev/null -w "refresh -> HTTP %{http_code}\n" -X POST -H 'content-type: application/json' -d "{\"projectID\":\"$PID\"}" "$B/api/worktree/refresh"; done
sleep 1
echo "== WARN lines in log:"
grep -rh "worktree discovery failed" $XDG_DATA_HOME/opencode/log/ $HOME/serve.out 2>/dev/null
echo "count: $(grep -rh 'worktree discovery failed' $XDG_DATA_HOME/opencode/log/ 2>/dev/null | wc -l)"
Still reproducible on 2.3.0 (Windows 11, desktop app) with an existing non-git project folder.
12 warnings today in ~3 hours, one per POST /api/worktree/refresh (clients call it when opening or refreshing a project).
Worktree.refresh -> WorktreeGit.list -> git.repo.discover() returns undefined -> DirectoryUnavailableError -> caught and logged as WARN in packages/core/src/worktree.ts.
No functional impact; the worktree list is just empty.
PR #58025 already returns an empty list for an existing non-git directory and is still a draft with no review since Oct 22. Could it be reviewed and landed so the warning stops on every refresh?
Activity
opencode-agent commentedon Oct 22, 2026
Thanks for the clear report. I could reproduce this on 2.1.2, and it still happens on the latest
dev(248bfbe).Steps: start
opencode serveinside a folder that exists but isn't a git repository, open that folder as a project, then call the worktree refresh endpoint (POST /api/worktree/refresh). Each refresh adds one line toopencode.log:The script below reproduces it. In the code, the git worktree strategy reports "directory unavailable" whenever it finds no git repository, even though the folder exists, and the refresh logs that as a warning every time. So the count in your log grows with how often the app refreshes worktrees for those projects. I've passed this to the maintainers along with the details.
Reproduction script (repro.sh)
Run it:
bash repro.shMercuryOoO commentedon Nov 13, 2026
Still reproducible on 2.3.0 (Windows 11, desktop app) with an existing non-git project folder.
POST /api/worktree/refresh(clients call it when opening or refreshing a project).Worktree.refresh->WorktreeGit.list->git.repo.discover()returns undefined ->DirectoryUnavailableError-> caught and logged as WARN inpackages/core/src/worktree.ts.PR #58025 already returns an empty list for an existing non-git directory and is still a draft with no review since Oct 22. Could it be reviewed and landed so the warning stops on every refresh?