{"record":{"id":"b5e859e02a514ad1","repo":"paperclipai/paperclip","slug":"failed-to-prepare-workspace-build-artifacts-before-b5e859","errorCode":null,"errorMessage":"Failed to prepare workspace build artifacts before starting the Paperclip dev server.","messagePattern":"Failed to prepare workspace build artifacts before starting the Paperclip dev server\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/run.ts","lineNumber":179,"sourceCode":"\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.\",\n    );\n  }\n}\n\nasync function importServerEntry(): Promise<StartedServer> {\n  // Dev mode: try local workspace path (monorepo with tsx)\n  const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), \"../../..\");\n  const devEntry = path.resolve(projectRoot, \"server/src/index.ts\");\n  if (fs.existsSync(devEntry)) {\n    ensureDevWorkspaceBuildDeps(projectRoot);\n    maybeEnableUiDevMiddleware(devEntry);\n    const mod = await import(pathToFileURL(devEntry).href);\n    return await startServerFromModule(mod, devEntry);\n  }\n\n  // Production mode: import the published @paperclipai/server package\n  try {","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/run.ts#L161-L197","documentation":"Thrown by ensureDevWorkspaceBuildDeps() when the plugin build-deps script launched successfully but exited with a non-zero status. Unlike error 169, the spawn succeeded; the script itself failed (compile error, missing dep, plugin build failure).","triggerScenarios":"Running dev server boot inside the monorepo; `scripts/ensure-plugin-build-deps.mjs` runs via spawnSync with stdio inherit and returns `result.status` other than 0 (or null, which the `?? 1` coerces to failure).","commonSituations":"A plugin package fails to build because its dependencies are not installed, a TypeScript error in a plugin, or a stale dist after a branch switch. The script's own output (inherited to the terminal) shows the real cause before this throw.","solutions":["Scroll up: the script's stderr/stdout is printed before the error — fix the reported build failure.","Reinstall plugins/workspace deps: `pnpm install`.","Clean and rebuild plugin packages per the repo's build instructions.","Run `node scripts/ensure-plugin-build-deps.mjs` directly to iterate."],"exampleFix":"# before: dev boot fails with non-zero build exit\npaperclipai run\n# after: reproduce and fix the plugin build\nnode scripts/ensure-plugin-build-deps.mjs\npnpm -r build","handlingStrategy":"try-catch","validationCode":"import { spawnSync } from 'node:child_process';\nfunction runBuildDeps(projectRoot: string): void {\n  const r = spawnSync(process.execPath, ['scripts/ensure-plugin-build-deps.mjs'], {cwd: projectRoot, stdio: 'inherit'});\n  if (r.error || (r.status ?? 1) !== 0) throw new Error('Build deps failed; see output above.');\n}","typeGuard":null,"tryCatchPattern":"const status = spawnSync(process.execPath, [script], {stdio: 'inherit'}).status ?? 1;\nif (status !== 0) {\n  console.error('Plugin build deps exited', status);\n  process.exit(status);\n}","preventionTips":["Keep plugin packages buildable independently so ensure-plugin-build-deps stays green.","Run `pnpm -r build` after branch switches to avoid stale plugin dists."],"tags":["dev","build","workspace","plugins","run"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}