{"record":{"id":"4c75d83bff5cccb7","repo":"mastra-ai/mastra","slug":"failed-to-copy-studio-assets-from-studiosource-4c75d8","errorCode":null,"errorMessage":"Failed to copy studio assets from \"${studioSource}\" to \"${staticDir}\": ${err instanceof Error ? err.message : err}","messagePattern":"Failed to copy studio assets from \"(.+?)\" to \"(.+?)\": (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deployers/vercel/src/index.ts","lineNumber":63,"sourceCode":"    await super.prepare(outputDirectory);\n\n    const __filename = fileURLToPath(import.meta.url);\n    const __dirname = dirname(__filename);\n\n    const studioSource = join(dirname(__dirname), 'dist', 'studio');\n\n    this.writeVercelJSON(\n      join(outputDirectory, this.outputDir, '..', '..'),\n      this.studio ? this.readStudioRouteRoots(studioSource) : [],\n    );\n\n    if (this.studio) {\n      const staticDir = join(outputDirectory, '.vercel', 'output', 'static');\n\n      try {\n        await copy(studioSource, staticDir, { overwrite: true });\n      } catch (err) {\n        throw new Error(\n          `Failed to copy studio assets from \"${studioSource}\" to \"${staticDir}\": ${err instanceof Error ? err.message : err}`,\n        );\n      }\n\n      this.injectStudioConfig(staticDir);\n    }\n  }\n\n  /**\n   * Studio's top-level route segments, emitted by the Studio build alongside index.html.\n   * The Vercel route table needs them explicitly: custom `registerApiRoute()` paths are mounted\n   * at the root of the server, so the function has to own every path Studio doesn't claim.\n   */\n  private readStudioRouteRoots(studioSource: string): string[] {\n    const manifestPath = join(studioSource, 'routes-manifest.json');\n\n    try {\n      const roots = JSON.parse(readFileSync(manifestPath, 'utf-8'));","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/deployers/vercel/src/index.ts#L45-L81","documentation":"The Vercel deployer's prepare() copies prebuilt studio static assets into the Vercel output static directory (.vercel/output/static). If the copy operation fails for any reason (missing source, permissions, disk error), it wraps the underlying error in this descriptive message so you know which step of deployment failed.","triggerScenarios":"Deploying with this.studio enabled while studioSource does not exist (studio not built first), or copy() failing due to permissions, ENOSPC, or EBUSY on .vercel/output/static.","commonSituations":"Forgetting to run the studio build before deploying; deploying from a container/user without write access to the output directory; stale file locks in CI.","solutions":["Build the studio so studioSource exists before running the Vercel deployer.","Check the inner error (the message includes err.message) and fix the root cause (permissions, disk space).","Ensure .vercel/output/static is writable and not locked by another process.","Verify the outputDirectory option points to the correct build directory."],"exampleFix":"// before\nnpx vercel deploy  # studio never built\n// after\npnpm build:studio && npx vercel deploy","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs';\nif (!existsSync(studioSource)) {\n  throw new Error(`Studio assets not built: ${studioSource} missing. Run the studio build first.`);\n}","typeGuard":"function isNodeError(err: unknown): err is Error {\n  return err instanceof Error;\n}","tryCatchPattern":"try {\n  await deployer.prepare();\n} catch (err) {\n  if (String((err as Error).message).startsWith('Failed to copy studio assets')) {\n    console.error('Studio build missing or copy failed:', (err as Error).message);\n    // rebuild studio then retry\n  }\n  throw err;\n}","preventionTips":["Always build the studio before invoking the Vercel deployer.","Add a build-order check in CI (studio build must precede deploy).","Verify write permissions on .vercel/output/static.","Read the inner err.message embedded in the error for the root cause."],"tags":["deployer","vercel","filesystem","build"],"backgroundTag":"asset-copy-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}