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
Snapshots fail for Locations opened through symlinked paths #54454
Snapshots are unavailable when a v2 Location is opened through a symlinked path. The Git worktree path is canonicalized, but the Location path is not, so snapshot capture incorrectly decides that the Location is outside the project and returns undefined.
Plugins
None
OpenCode version
v2 branch
Steps to reproduce
Create a Git project at /tmp/real/project with one tracked file.
Create /tmp/linked as a directory symlink to /tmp/real.
Open the Location as /tmp/linked/project.
Trigger a snapshot capture.
Observed: capture logs Location is outside the project and returns no snapshot.
Expected: the symlinked Location is recognized as the same project and a snapshot is created.
Thanks for the clear report. I could reproduce this on the latest dev (e31136b).
With a Git repo at <tmp>/real/project and <tmp>/linked symlinked to <tmp>/real:
a Location opened at <tmp>/real/project gets a snapshot ID from Snapshot.capture()
a Location opened at <tmp>/linked/project gets undefined
The cause is in packages/core/src/snapshot.ts. The Git worktree path is resolved with realPath, but the Location directory is not, so the containment check in scope() fails with "Location is outside the project" and capture() swallows the error.
The script below reproduces it as a packages/core Bun test.
Related: #52224 (resolves symlinks before the external_directory boundary check, a similar fix in another component) and #40160.
// Reproduction for https://github.com/anomalyco/opencode/issues/54454// Run from packages/core: bun test test/snapshot-symlink-repro.test.tsimport{$}from"bun"import{describe,expect}from"bun:test"importfsfrom"fs/promises"importpathfrom"path"import{Effect,Layer}from"effect"import{AppNodeBuilder}from"@opencode/core/effect/app-node-builder"import{Global}from"@opencode/util/global"import{Location}from"@opencode/core/location"import{AbsolutePath}from"@opencode/core/schema"import{Snapshot}from"@opencode/core/snapshot"import{tmpdir}from"./fixture/tmpdir"import{testEffect}from"./lib/effect"functionsnapshotLayer(data: string,directory: string){returnAppNodeBuilder.build(Snapshot.node,[Location.node.replace(Location.boundNode(Location.Ref.make({directory: AbsolutePath.make(directory)}))),Global.node.replace(Global.layerWith({ data,config: path.join(data,"config")})),])}constcapture=(data: string,directory: string)=>Effect.gen(function*(){constsnapshot=yield*Snapshot.Servicereturnyield*snapshot.capture()}).pipe(Effect.provide(snapshotLayer(data,directory)))describe("Snapshot via symlinked Location (#54454)",()=>{testEffect(Layer.empty).live("real path vs symlinked path",()=>Effect.acquireUseRelease(Effect.promise(()=>tmpdir()),(tmp)=>Effect.gen(function*(){constreal=path.join(tmp.path,"real")constproject=path.join(real,"project")constlinked=path.join(tmp.path,"linked")yield*Effect.promise(async()=>{awaitfs.mkdir(project,{recursive: true})awaitfs.writeFile(path.join(project,"tracked.txt"),"one\n")await$`git init -q`.cwd(project).quiet()await$`git add .`.cwd(project).quiet()await$`git -c user.email=t@t -c user.name=t commit -q --no-gpg-sign -m init`.cwd(project).quiet()awaitfs.symlink(real,linked,"dir")})constviaReal=yield*capture(path.join(tmp.path,"data-real"),project)constviaLink=yield*capture(path.join(tmp.path,"data-link"),path.join(linked,"project"))console.log("capture via real path: ",viaReal)console.log("capture via symlinked path:",viaLink)expect(viaReal).toBeDefined()expect(viaLink).toBeDefined()// fails: undefined, "Location is outside the project"}),(tmp)=>Effect.promise(()=>tmp[Symbol.asyncDispose]()),),)})
Activity
opencode-agent commentedon Oct 11, 2026
Thanks for the clear report. I could reproduce this on the latest
dev(e31136b).With a Git repo at
<tmp>/real/projectand<tmp>/linkedsymlinked to<tmp>/real:<tmp>/real/projectgets a snapshot ID fromSnapshot.capture()<tmp>/linked/projectgetsundefinedThe cause is in
packages/core/src/snapshot.ts. The Git worktree path is resolved withrealPath, but the Location directory is not, so the containment check inscope()fails with "Location is outside the project" andcapture()swallows the error.The script below reproduces it as a
packages/coreBun test.Related: #52224 (resolves symlinks before the
external_directoryboundary check, a similar fix in another component) and #40160.Reproduction script (snapshot-symlink-repro.test.ts)
Run it:
bun snapshot-symlink-repro.test.ts