From 18af97688d4c3beee318b917eeb1db8a67655ce3 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Fri, 20 Nov 2026 08:00:51 +0100 Subject: [PATCH] fix(skills): finish removing reachable skills during uninstall when one root is unreadable Continue across every target root in `removeSkill` and every managed skill in `uninstallSkills` before throwing the first error (matching `syncSkills`), while still reporting `EACCES` rather than ignoring it. --- .../internal/controller.test.ts | 10 ++++++++++ .../internal/operations.ts | 18 ++++++++++++++---- .../orchestration-skills/internal/sync.ts | 16 ++++++++++++---- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/packages/server/src/server/orchestration-skills/internal/controller.test.ts b/packages/server/src/server/orchestration-skills/internal/controller.test.ts index 8d3accc376..b82d89d6e5 100644 --- a/packages/server/src/server/orchestration-skills/internal/controller.test.ts +++ b/packages/server/src/server/orchestration-skills/internal/controller.test.ts @@ -1323,6 +1323,16 @@ describe("skills controller", () => { } finally { await chmod(geminiHome, 0o755); } + + // With ~/.gemini unreadable (0000), uninstall still removes every skill from healthy targets. + await chmod(geminiHome, 0o000); + try { + await expect(harness.controller.uninstall()).rejects.toThrow(); + expect(await installedSkills(harness.targets.agentsDir)).toEqual([]); + expect(await installedSkills(harness.targets.claudeDir)).toEqual([]); + } finally { + await chmod(geminiHome, 0o755); + } }, ); diff --git a/packages/server/src/server/orchestration-skills/internal/operations.ts b/packages/server/src/server/orchestration-skills/internal/operations.ts index 7369a786a0..857002c2f2 100644 --- a/packages/server/src/server/orchestration-skills/internal/operations.ts +++ b/packages/server/src/server/orchestration-skills/internal/operations.ts @@ -259,11 +259,21 @@ export async function uninstallSkills( selection: SkillSelection, ): Promise { const available = await listBundledSkills(targets.sourceDir); + let hasError = false; + let firstError: unknown = null; for (const name of managedSkillNames(available)) { - await removeSkill(name, { - installDirs: targets.installDirs, - codexDir: targets.codexDir, - }); + try { + await removeSkill(name, { + installDirs: targets.installDirs, + codexDir: targets.codexDir, + }); + } catch (error) { + if (!hasError) { + hasError = true; + firstError = error; + } + } } + if (hasError) throw firstError; return getSkillsStatus(targets, selection); } diff --git a/packages/server/src/server/orchestration-skills/internal/sync.ts b/packages/server/src/server/orchestration-skills/internal/sync.ts index 57bf67e761..b773d93ee6 100644 --- a/packages/server/src/server/orchestration-skills/internal/sync.ts +++ b/packages/server/src/server/orchestration-skills/internal/sync.ts @@ -178,13 +178,21 @@ export async function removeSkill(skillName: string, targets: RemoveSkillTargets const paths = [...targets.installDirs, targets.codexDir].map((root) => path.join(root, skillName), ); + let hasError = false; + let firstError: unknown = null; for (const p of paths) { - await fs.rm(p, { recursive: true, force: true }).catch((error: NodeJS.ErrnoException) => { + try { + await fs.rm(p, { recursive: true, force: true }); + } catch (error) { // If an ancestor is a regular file, no skill directory can exist below it. - if (error.code === "ENOTDIR") return; - throw error; - }); + if ((error as NodeJS.ErrnoException).code === "ENOTDIR") continue; + if (!hasError) { + hasError = true; + firstError = error; + } + } } + if (hasError) throw firstError; } async function isSameDirectory(a: string, b: string): Promise {