{"record":{"id":"8feda21a5904537e","repo":"deepseek-ai/deepseek-harness","slug":"dsh-link-exists-and-is-not-a-symlink-remove-i","errorCode":null,"errorMessage":"dsh: ${link} exists and is not a symlink; remove it so dsh can manage the installation fallback","messagePattern":"dsh: (.+?) exists and is not a symlink; remove it so dsh can manage the installation fallback","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/boot/app-boot/src/profile.ts","lineNumber":182,"sourceCode":"  const patchPath = join(dir, PROFILE_PATCH_FILENAME)\n  if (!existsSync(patchPath)) writeFileSync(patchPath, PROFILE_PATCH_TEMPLATE)\n  const workspacePath = join(dir, 'pnpm-workspace.yaml')\n  if (!existsSync(workspacePath)) writeFileSync(workspacePath, PROFILE_PNPM_WORKSPACE)\n}\n\n/** Ensure `link` is a symlink to `target`, replacing a wrong or dangling link; a real directory throws. */\nfunction ensureSymlink(link: string, target: string): void {\n  let stat\n  try {\n    stat = lstatSync(link)\n  } catch {\n    // Missing link (first run) — created below. Any other lstat failure on a\n    // path we just created the parent of would resurface on symlinkSync.\n    stat = undefined\n  }\n  if (stat !== undefined) {\n    if (!stat.isSymbolicLink()) {\n      throw new Error(`dsh: ${link} exists and is not a symlink; remove it so dsh can manage the installation fallback`)\n    }\n    if (readlinkSync(link) === target) return\n    // unlink deletes the reparse point itself on Windows too; rmSync treats a\n    // junction as a directory and throws EISDIR unless recursive.\n    unlinkSync(link)\n  }\n  try {\n    symlinkSync(target, link, 'junction')\n  } catch (error) {\n    // Concurrent launches heal the same fallback; losing the race to a\n    // process writing the identical link is success, anything else is not.\n    // The window between the lstat miss above and this write cannot be\n    // staged deterministically from the public API.\n    /* v8 ignore next 4 */\n    if ((error as NodeJS.ErrnoException).code !== 'EEXIST'\n      || !lstatSync(link).isSymbolicLink() || readlinkSync(link) !== target) {\n      throw error\n    }","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/boot/app-boot/src/profile.ts#L164-L200","documentation":"Error \"dsh: ${link} exists and is not a symlink; remove it so dsh can manage the installation fallback\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/boot/app-boot/src/profile.ts:182 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the non-symlink path so dsh can manage the installation fallback."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}