Skip to content

Commit a8a9b4b

Browse files
committed
fix(watcher): resolve symlinked .git path before subscribing
inotify_add_watch fails with 'Not a directory' when the .git path is a symlink (common with Android's repo tool). Resolve the path with realpath before passing it to @parcel/watcher so the inotify backend receives the real directory path. Fixes #26981
1 parent 7cc968b commit a8a9b4b

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

packages/opencode/src/file/watcher.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Cause, Effect, Layer, Context, Schema } from "effect"
22
// @ts-ignore
33
import { createWrapper } from "@parcel/watcher/wrapper"
44
import type ParcelWatcher from "@parcel/watcher"
5-
import { readdir } from "fs/promises"
5+
import { readdir, realpath } from "fs/promises"
66
import path from "path"
77
import { Bus } from "@/bus"
88
import { BusEvent } from "@/bus/bus-event"
@@ -131,7 +131,10 @@ export const layer = Layer.effect(
131131
const result = yield* git.run(["rev-parse", "--git-dir"], {
132132
cwd: ctx.worktree,
133133
})
134-
const vcsDir = result.exitCode === 0 ? path.resolve(ctx.worktree, result.text().trim()) : undefined
134+
const resolved = result.exitCode === 0 ? path.resolve(ctx.worktree, result.text().trim()) : undefined
135+
const vcsDir = resolved
136+
? yield* Effect.promise(() => realpath(resolved).catch(() => resolved))
137+
: undefined
135138
if (vcsDir && !cfgIgnores.includes(".git") && !cfgIgnores.includes(vcsDir)) {
136139
const ignore = (yield* Effect.promise(() => readdir(vcsDir).catch(() => []))).filter(
137140
(entry) => entry !== "HEAD",

0 commit comments

Comments
 (0)