{"record":{"id":"4b8409e64c09618d","repo":"upstash/context7","slug":"fix-permissions-with","errorCode":null,"errorMessage":"Fix permissions with:","messagePattern":"Fix permissions with:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/cli/src/commands/skill.ts","lineNumber":464,"sourceCode":"          throw dirErr;\n        }\n      }\n\n      installedSkills.push(`${skill.project}/${skill.name}`);\n    } catch (err) {\n      const error = err as NodeJS.ErrnoException;\n      if (error.code === \"EACCES\" || error.code === \"EPERM\") {\n        continue;\n      }\n      const errMsg = err instanceof Error ? err.message : String(err);\n      log.warn(`Failed to install ${skill.name}: ${errMsg}`);\n    }\n  }\n\n  if (permissionError) {\n    installSpinner.fail(\"Permission denied\");\n    log.blank();\n    log.warn(\"Fix permissions with:\");\n    for (const dir of failedDirs) {\n      const parentDir = join(dir, \"..\");\n      log.dim(`  sudo chown -R $(whoami) \"${parentDir}\"`);\n    }\n    log.blank();\n    return;\n  }\n\n  installSpinner.succeed(`Installed ${installedSkills.length} skill(s)`);\n  trackEvent(\"install\", { skills: installedSkills, ides: targets.ides });\n\n  const installedNames = selectedSkills.map((s) => s.name);\n  logInstallSummary(targets, targetDirs, installedNames);\n}\n\nasync function searchCommand(query: string): Promise<void> {\n  trackEvent(\"command\", { name: \"search\" });\n  log.blank();","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/upstash/context7/blob/4416fb855b8f752be735e34f943b5d0762701aad/packages/cli/src/commands/skill.ts#L446-L482","documentation":"A warning printed by `skill install` after installation fails with EACCES/EPERM on one or more target directories. The spinner fails with 'Permission denied' and this warning heads a list of suggested `sudo chown` commands that give the current user ownership of each failed directory's parent.","triggerScenarios":"The filesystem write (mkdir/copy of skill files) into a target directory (e.g. a global skills dir under a root-owned path) is rejected due to insufficient permissions; permissionError is set and failedDirs is non-empty.","commonSituations":"Installing global skills into a system-managed path created by sudo/root previously; shared machine where ~/.config or ~/.opencode subdirectories are owned by another user; running with different users across versions so cached dirs got root-owned.","solutions":["Run the suggested fix: sudo chown -R $(whoami) \"<parent-dir>\" for each printed failed directory, then retry the install","Install to a target directory the current user owns instead of the system path","If sudo chown is not appropriate, copy skill files manually into a writable location","Check ownership first with ls -ld on the failing directory to confirm the culprit"],"exampleFix":"// before (install fails with EACCES)\n$ opencode skill install org/skills\nPermission denied\n// after\n$ sudo chown -R $(whoami) \"$HOME/.opencode\"\n$ opencode skill install org/skills   # succeeds","handlingStrategy":"validation","validationCode":"import { accessSync, W_OK } from 'node:fs';\nfor (const dir of targetDirs) {\n  try { accessSync(dir, W_OK); } catch {\n    console.error(`Not writable: ${dir}. Fix: sudo chown -R $(whoami) \"${join(dir, '..')}\"`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await installSkills(skills, targetDirs);\n} catch (e) {\n  if (e.code === 'EACCES' || e.code === 'EPERM') {\n    console.warn('Fix permissions with: sudo chown -R $(whoami) \"<parent-dir>\"');\n  }\n  throw e;\n}","preventionTips":["Never run installs with sudo; keep user dirs user-owned","Periodically check ownership of ~/.opencode / ~/.config paths","Pre-create target dirs as the current user"],"tags":["cli","permissions","filesystem","install-failed"],"backgroundTag":"file-write-permission-denied","analyzedSha":"4416fb855b8f752be735e34f943b5d0762701aad","analyzedAt":"2026-09-16T20:28:07.148Z","contentChangedAt":"2026-09-16T20:28:07.148Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}