{"record":{"id":"b076e627e806e129","repo":"mastra-ai/mastra","slug":"failed-to-copy-studio-assets-from-studiosource","errorCode":null,"errorMessage":"Failed to copy studio assets from \"${studioSource}\" to \"${studioServePath}\": ${err instanceof Error ? err.message : err}","messagePattern":"Failed to copy studio assets from \"(.+?)\" to \"(.+?)\": (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deployers/sandbox/src/deployer.ts","lineNumber":124,"sourceCode":"      mastra.__registerInternalWorkflow(scoreTracesWorkflow);\n    }\n    `;\n  }\n\n  async prepare(outputDirectory: string): Promise<void> {\n    await super.prepare(outputDirectory);\n\n    if (this.studio) {\n      const __filename = fileURLToPath(import.meta.url);\n      const __dirname = dirname(__filename);\n\n      const studioSource = join(dirname(__dirname), 'dist', 'studio');\n      const studioServePath = join(outputDirectory, this.outputDir, 'studio');\n\n      try {\n        await copy(studioSource, studioServePath, { overwrite: true });\n      } catch (err) {\n        throw new Error(\n          `Failed to copy studio assets from \"${studioSource}\" to \"${studioServePath}\": ${err instanceof Error ? err.message : err}`,\n        );\n      }\n    }\n  }\n\n  async bundle(\n    entryFile: string,\n    outputDirectory: string,\n    { toolsPaths, projectRoot }: { toolsPaths: (string | string[])[]; projectRoot: string },\n  ): Promise<void> {\n    return this._bundle(this.getEntry(), entryFile, { outputDirectory, projectRoot }, toolsPaths);\n  }\n\n  /**\n   * Deploy the built output into the sandbox and wait for the server to come\n   * up on its public URL. Writes `sandbox-deployment.json` into the output\n   * directory and updates the Edge Config alias when configured.","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/deployers/sandbox/src/deployer.ts#L106-L142","documentation":"The sandbox deployer's prepare step copies the bundled Studio UI assets from the package's dist/studio directory into the deploy output directory. If the recursive copy (fs copy with overwrite) fails for any reason, it is wrapped in this error preserving the original message and both paths.","triggerScenarios":"prepare() runs and copy(studioSource, studioServePath) throws — e.g. the source dist/studio doesn't exist, the output directory is not writable, disk is full, or a filesystem error (EPERM/ENOENT/ENOSPC) occurs.","commonSituations":"Installing @mastra/deployers-sandbox with a bundler that strips non-JS assets so dist/studio is missing; read-only CI filesystem or missing write permissions on outputDirectory; partial installs with corrupted package contents.","solutions":["Read the wrapped inner message for the underlying fs error","Verify node_modules/@mastra/deployers-sandbox/dist/studio exists (reinstall if missing)","Check write permissions and disk space on outputDirectory","Avoid bundlers/minifiers that prune package dist assets for this deployer"],"exampleFix":"// before (bundler externals pruning assets)\n// after: mark package as external / install via package manager\npnpm install --force @mastra/deployers-sandbox\nchmod -R u+w ./output","handlingStrategy":"try-catch","validationCode":"import { existsSync } from 'node:fs';\nconst studioSource = join(dirname(require.resolve('@mastra/deployers-sandbox')), 'dist', 'studio');\nif (!existsSync(studioSource)) throw new Error('package install is missing dist/studio — reinstall');\nif (process.getuid && !accessOk(outputDirectory)) await fs.mkdir(outputDirectory, { recursive: true });","typeGuard":null,"tryCatchPattern":"try {\n  await deployer.prepare(outputDirectory);\n} catch (err) {\n  if (String(err).startsWith('Failed to copy studio assets')) {\n    console.error('check dist/studio exists and outputDirectory is writable:', err.message);\n  } else throw err;\n}","preventionTips":["Reinstall the package if dist/studio is missing","Verify write permissions and free disk space on outputDirectory in CI","Avoid bundling steps that strip package dist assets"],"tags":["filesystem","studio-assets","deployment","build"],"backgroundTag":"file-copy-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}