From a79c1005941fa2b3081e71c127b02fcc008cea3a Mon Sep 17 00:00:00 2001 From: Ayaan Zaidi Date: Tue, 6 Jan 2026 11:06:11 +0530 Subject: [PATCH] fix: targetDir symlink handling in postinstall script (#272) --- scripts/postinstall.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/postinstall.js b/scripts/postinstall.js index 8dd5e8b2d..f849c02fd 100644 --- a/scripts/postinstall.js +++ b/scripts/postinstall.js @@ -25,12 +25,16 @@ function applyPatchIfNeeded(opts) { throw new Error(`missing patch: ${patchPath}`); } - const targetDir = path.resolve(opts.targetDir); + let targetDir = path.resolve(opts.targetDir); if (!fs.existsSync(targetDir) || !fs.statSync(targetDir).isDirectory()) { console.warn(`[postinstall] skip missing target: ${targetDir}`); return; } + // Resolve symlinks to avoid "beyond a symbolic link" errors from git apply + // (bun/pnpm use symlinks in node_modules) + targetDir = fs.realpathSync(targetDir); + const gitArgsBase = ["apply", "--unsafe-paths", "--whitespace=nowarn"]; const reverseCheck = [ ...gitArgsBase,