{"record":{"id":"18a4ed9420b1a326","repo":"mastra-ai/mastra","slug":"failure-in-install-step-installresult-error","errorCode":null,"errorMessage":"Failure in install step: ${installResult.error || 'Install failed'}","messagePattern":"Failure in install step: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent-builder/src/workflows/template-builder/template-builder.ts","lineNumber":1667,"sourceCode":"      packageInfo: packageResult,\n    };\n  })\n  .then(packageMergeStep)\n  .map(async ({ getInitData }) => {\n    const initData = getInitData<AgentBuilderInputSchemaType>();\n    return {\n      targetPath: initData.targetPath,\n    };\n  })\n  .then(installStep)\n  .map(async ({ getStepResult, getInitData }) => {\n    const cloneResult = getStepResult(cloneTemplateStep);\n    const orderResult = getStepResult(orderUnitsStep);\n    const installResult = getStepResult(installStep);\n    const initData = getInitData<AgentBuilderInputSchemaType>();\n\n    if (shouldAbortWorkflow(installResult)) {\n      throw new Error(`Failure in install step: ${installResult.error || 'Install failed'}`);\n    }\n    return {\n      orderedUnits: orderResult.orderedUnits,\n      templateDir: cloneResult.templateDir,\n      commitSha: cloneResult.commitSha,\n      slug: cloneResult.slug,\n      targetPath: initData.targetPath,\n      variables: initData.variables,\n    };\n  })\n  .then(programmaticFileCopyStep)\n  .map(async ({ getStepResult, getInitData }) => {\n    const copyResult = getStepResult(programmaticFileCopyStep);\n    const cloneResult = getStepResult(cloneTemplateStep);\n    const initData = getInitData<AgentBuilderInputSchemaType>();\n\n    return {\n      conflicts: copyResult.conflicts,","sourceCodeStart":1649,"sourceCodeEnd":1685,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/agent-builder/src/workflows/template-builder/template-builder.ts#L1649-L1685","documentation":"After orderUnitsStep and installStep run, this map step checks shouldAbortWorkflow(installResult) and throws 'Failure in install step' with the installer's error or 'Install failed'. Dependency installation into the cloned template failed, so the build aborts before configuration/finishing steps.","triggerScenarios":"installStep aborted during package installation in the cloned templateDir: package manager (npm/pnpm/yarn) exited non-zero due to unresolvable dependency versions, missing lockfile compatibility, registry/network errors, or missing build tooling in the environment.","commonSituations":"Template pins dependencies that no longer resolve, private registry packages without auth tokens, lockfile generated by a different package-manager major version, peer-dependency conflicts, or offline/CI environments without network access to the registry.","solutions":["Read installResult.error for the package manager's actual failure and address that dependency/registry issue","Run the install command manually inside the cloned template directory to reproduce and see full logs","Align the package manager version with the template's lockfile (e.g. correct corepack/pnpm version)","Check registry authentication for private packages and network access from the runtime environment","Retry on transient registry/network errors"],"exampleFix":"// before (template package.json)\n\"dependencies\": { \"left-pad\": \"^99.0.0\" }\n// after — pin a resolvable version\n\"dependencies\": { \"left-pad\": \"^1.3.0\" }","handlingStrategy":"retry","validationCode":"const { execSync } = require('node:child_process');\nexport function assertInstallable(dir: string, cmd = 'npm install --dry-run') {\n  execSync(cmd, { cwd: dir, stdio: 'ignore' }); // throws if deps cannot resolve\n}\n// run in the cloned template dir before invoking install-dependent workflows","typeGuard":"export function installSucceeded(r: { error?: string; [k: string]: unknown }) {\n  return r != null && !r.error;\n}","tryCatchPattern":"try {\n  await run.start({ ... });\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Failure in install step:')) {\n    const cause = e.message.replace('Failure in install step: ', '');\n    if (cause === 'Install failed') { /* enable install-step logs for the package-manager output */ }\n    // retry transient registry errors with backoff\n  }\n  throw e;\n}","preventionTips":["Pin resolvable dependency versions in template package.json and keep the lockfile in sync","Match the package manager version to the lockfile (corepack/packageManager field)","Configure registry auth tokens for private packages in the runtime environment","Pre-warm/verify registry access in CI and air-gapped environments"],"tags":["install","dependencies","workflow","template-builder"],"backgroundTag":"dependency-install-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}