{"record":{"id":"716d4f548043ef58","repo":"paperclipai/paperclip","slug":"refusing-to-use-unsafe-shim-directory-directoryp","errorCode":null,"errorMessage":"Refusing to use unsafe shim directory ${directoryPath}.","messagePattern":"Refusing to use unsafe shim directory (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/install-store.ts","lineNumber":357,"sourceCode":"    for (const entry of fs.readdirSync(sourceRoot)) {\n      if (entry.startsWith(\".\")) continue;\n      const candidate = path.join(sourceRoot, entry);\n      if (!retained.has(path.resolve(candidate))) {\n        fs.rmSync(candidate, { recursive: true, force: true });\n        removed.push(candidate);\n      }\n    }\n  }\n  return removed;\n}\n\nexport function assertManagedShimWritable(paths = resolveInstallStorePaths()): void {\n  const homeDir = path.dirname(path.dirname(path.dirname(paths.shimPath)));\n  for (const directoryPath of [homeDir, path.join(homeDir, \".local\"), path.dirname(paths.shimPath)]) {\n    if (!fs.existsSync(directoryPath)) continue;\n    const directoryStat = fs.lstatSync(directoryPath);\n    if (!directoryStat.isDirectory() || directoryStat.isSymbolicLink()) {\n      throw new Error(`Refusing to use unsafe shim directory ${directoryPath}.`);\n    }\n    assertOwnedByCurrentUser(directoryStat, directoryPath);\n  }\n  try {\n    const stat = fs.lstatSync(paths.shimPath);\n    if (!stat.isFile() || stat.isSymbolicLink()) {\n      throw new Error(`Refusing to replace non-regular shim ${paths.shimPath}.`);\n    }\n    assertOwnedByCurrentUser(stat, paths.shimPath);\n    if (stat.nlink > 1) throw new Error(`Refusing to replace multiply linked shim ${paths.shimPath}.`);\n    const existing = fs.readFileSync(paths.shimPath, \"utf8\");\n    if (!isManagedShimContents(existing)) {\n      throw new Error(`Refusing to replace existing non-managed command ${paths.shimPath}.`);\n    }\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n  }\n}","sourceCodeStart":339,"sourceCodeEnd":375,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/cli/src/install-store.ts#L339-L375","documentation":"assertManagedShimWritable checks the ~/.local/bin chain and found a non-directory or symlink where a directory is expected; the guard refuses to write the shim through unsafe paths.","triggerScenarios":"Thrown at cli/src/install-store.ts:357 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a shim directory owned by the current user and not a symlink: ${directoryPath}."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}