{"record":{"id":"9d2010ab3f6ab75b","repo":"mastra-ai/mastra","slug":"could-not-find-workspace-root","errorCode":null,"errorMessage":"Could not find workspace root","messagePattern":"Could not find workspace root","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/deployer/src/bundler/workspaceDependencies.ts","lineNumber":129,"sourceCode":"}): TransitiveDependencyResult => {\n  const usedWorkspacePackages = new Set<string>();\n  const queue: string[] = Array.from(initialDependencies);\n  const resolutions: Record<string, string> = {};\n\n  while (queue.length > 0) {\n    const len = queue.length;\n    for (let i = 0; i < len; i += 1) {\n      const pkgName = queue.shift();\n      if (!pkgName || usedWorkspacePackages.has(pkgName)) {\n        continue;\n      }\n\n      const dep = workspaceMap.get(pkgName);\n      if (!dep) continue;\n\n      const root = findWorkspacesRoot();\n      if (!root) {\n        throw new Error('Could not find workspace root');\n      }\n\n      const depsService = new DepsService(root.location);\n      depsService.__setLogger(logger);\n      const sanitizedName = slugify(pkgName);\n\n      const tgzPath = depsService.getWorkspaceDependencyPath({\n        pkgName: sanitizedName,\n        version: dep.version!,\n      });\n      resolutions[pkgName] = tgzPath;\n      usedWorkspacePackages.add(pkgName);\n\n      for (const [depName, _depVersion] of Object.entries(dep?.dependencies ?? {})) {\n        if (!usedWorkspacePackages.has(depName) && workspaceMap.has(depName)) {\n          queue.push(depName);\n        }\n      }","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/deployer/src/bundler/workspaceDependencies.ts#L111-L147","documentation":"collectTransitiveWorkspaceDependencies walks workspace packages transitively and needs the pnpm workspace root (where pnpm-workspace.yaml lives) to instantiate DepsService. If findWorkspacesRoot() cannot locate a workspace root, this plain Error is thrown. It only runs when workspace (link:) dependencies are present, so it implies your project should be a pnpm workspace.","triggerScenarios":"Calling the bundler/deploy pipeline on a project that has workspace: protocol dependencies (or is inside a monorepo) but where findWorkspacesRoot() finds no pnpm-workspace.yaml / packageManager field from the current directory upward.","commonSituations":"Running mastra build from a subdirectory whose parents lack pnpm-workspace.yaml; a standalone app that accidentally kept a \"workspace:^\" dependency copied from a monorepo; using npm/yarn workspaces where the finder expects pnpm conventions.","solutions":["Ensure a pnpm-workspace.yaml exists at your project/monorepo root and run the command from within that tree.","If this is a standalone (non-monorepo) project, replace any \"workspace:*\" / \"workspace:^\" dependency versions with real semver versions.","Confirm the package manager is pnpm and the workspace file wasn't excluded by .npmignore/docker COPY filters."],"exampleFix":"// before: package.json\n\"some-pkg\": \"workspace:*\"\n// after\n\"some-pkg\": \"^1.4.0\"","handlingStrategy":"validation","validationCode":"import { findWorkspacesRoot } from './bundler/workspaceDependencies';\nif (!findWorkspacesRoot()) throw new Error('Run from inside a pnpm workspace (pnpm-workspace.yaml missing)');\nfor (const [name, ver] of Object.entries(pkg.dependencies ?? {})) {\n  if (String(ver).startsWith('workspace:')) throw new Error(`Replace workspace: dep ${name} for standalone builds`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await mastra.deploy();\n} catch (e) {\n  if (e?.message === 'Could not find workspace root') {\n    console.error('Run mastra build from the monorepo root or inline your workspace deps.');\n  }\n  throw e;\n}","preventionTips":["Keep pnpm-workspace.yaml at the repo root and build from within the workspace","Avoid workspace: protocol deps in deployable standalone packages","In Docker, COPY pnpm-workspace.yaml and the lockfile before packages"],"tags":["deployer","pnpm","monorepo","workspace"],"backgroundTag":"workspace-root-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}