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
{{ message }}
Repository navigation
Snapshot fails when opencode is opened in a git subdirectory (snapshot service cwd mismatch) #27688
When opening opencode in a git repository subdirectory (e.g., src/), the snapshot service fails to track files with the error:
WARN service=snapshot exitCode=128 stderr=warning: cannot open directory 'src/src/': No such file or directory
fatal error: pathspec 'src/date.txt' did not match any files
failed to add snapshot files
Root Cause
The issue was introduced in packages/opencode/src/snapshot/index.ts.
In the stage, drop, and ignore functions, cwd is set to state.directory (the directory where opencode was launched), but files paths are relative to state.worktree (git repository root).
When --work-tree points to the repository root but cwd points to a subdirectory, git cannot resolve the paths correctly.
Affected Code
In packages/opencode/src/snapshot/index.ts:
ignore function: cwd: state.directory should be cwd: state.worktree
drop function: cwd: state.directory should be cwd: state.worktree
stage function: cwd: state.directory should be cwd: state.worktree
Expected Behavior
Snapshot should work correctly regardless of which directory within a git repository opencode is launched from.
Plugins
No response
OpenCode version
v1.15.0
Steps to reproduce
Initialize a git repository with some files
Open opencode from a subdirectory (e.g., cd src && opencode)
The snapshot service will fail with the error above
Activity