{"record":{"id":"45f2a3c8fd65f74e","repo":"paperclipai/paperclip","slug":"failed-to-prepare-workspace-build-artifacts-before","errorCode":null,"errorMessage":"Failed to prepare workspace build artifacts before starting the Paperclip dev server.\n${formatError(result.error)}","messagePattern":"Failed to prepare workspace build artifacts before starting the Paperclip dev server\\.\n(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/run.ts","lineNumber":199,"sourceCode":"\nfunction getMissingModuleSpecifier(err: unknown): string | null {\n  if (!(err instanceof Error)) return null;\n  const packageMatch = err.message.match(/Cannot find package '([^']+)' imported from/);\n  if (packageMatch?.[1]) return packageMatch[1];\n  const moduleMatch = err.message.match(/Cannot find module '([^']+)'/);\n  if (moduleMatch?.[1]) return moduleMatch[1];\n  return null;\n}\n\nfunction maybeEnableUiDevMiddleware(entrypoint: string): void {\n  if (process.env.PAPERCLIP_UI_DEV_MIDDLEWARE !== undefined) return;\n  const normalized = entrypoint.replaceAll(\"\\\\\", \"/\");\n  if (normalized.endsWith(\"/server/src/index.ts\") || normalized.endsWith(\"@paperclipai/server/src/index.ts\")) {\n    process.env.PAPERCLIP_UI_DEV_MIDDLEWARE = \"true\";\n  }\n}\n\nfunction ensureDevWorkspaceBuildDeps(projectRoot: string): void {\n  const buildScript = path.resolve(projectRoot, \"scripts/ensure-plugin-build-deps.mjs\");\n  if (!fs.existsSync(buildScript)) return;\n\n  const result = spawnSync(process.execPath, [buildScript], {\n    cwd: projectRoot,\n    stdio: \"inherit\",\n    timeout: 120_000,\n  });\n\n  if (result.error) {\n    throw new Error(\n      `Failed to prepare workspace build artifacts before starting the Paperclip dev server.\\n${formatError(result.error)}`,\n    );\n  }\n\n  if ((result.status ?? 1) !== 0) {\n    throw new Error(\n      \"Failed to prepare workspace build artifacts before starting the Paperclip dev server.\",","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/cli/src/commands/run.ts#L181-L217","documentation":"ensureDevWorkspaceBuildDeps spawnSync'd the build-prep script and it failed to spawn at all (error set); the original spawn error is wrapped with context about the dev-server preparation step.","triggerScenarios":"Thrown at cli/src/commands/run.ts:173 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the underlying build error in the output, fix the workspace build, and retry."],"exampleFix":null,"handlingStrategy":"try-catch","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"}