{"record":{"id":"36607f70a1bd6f26","repo":"prisma/prisma","slug":"could-not-find-monorepo-root-pnpm-workspace-yaml","errorCode":null,"errorMessage":"Could not find monorepo root (pnpm-workspace.yaml)","messagePattern":"Could not find monorepo root \\(pnpm-workspace\\.yaml\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/1-framework/3-tooling/cli/scripts/record.ts","lineNumber":136,"sourceCode":"    return execFileSync(process.execPath, [CLI_BIN, ...args.split(/\\s+/).filter(Boolean)], {\n      cwd,\n      encoding: 'utf-8',\n      env: { ...process.env, NO_COLOR: '1', CI: 'true' },\n      stdio: ['pipe', 'pipe', 'pipe'],\n    });\n  } catch (error: unknown) {\n    const e = error as { stdout?: string; stderr?: string };\n    return `${e.stdout ?? ''}${e.stderr ?? ''}`;\n  }\n}\n\nfunction findMonorepoRoot(startDir: string): string {\n  let dir = startDir;\n  while (dir !== '/') {\n    if (existsSync(join(dir, 'pnpm-workspace.yaml'))) return dir;\n    dir = dirname(dir);\n  }\n  throw new Error('Could not find monorepo root (pnpm-workspace.yaml)');\n}\n\nconst MONOREPO_ROOT = findMonorepoRoot(CLI_ROOT);\n\n/**\n * Workspace is created inside the test fixture app so jiti can resolve\n * workspace packages (adapter-postgres, driver-postgres, etc.) when\n * loading prisma-next.config.ts.\n */\nconst FIXTURE_APP_DIR = join(MONOREPO_ROOT, 'test/integration/test/fixtures/cli/cli-e2e-test-app');\n\n// --- Test utils (loaded dynamically to avoid adding deps to CLI package) ---\n\ninterface DbClient {\n  query(sql: string): Promise<unknown>;\n}\n\ninterface TestUtils {","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/prisma/prisma/blob/a20d61fb6f095e636e6420ac2871c24f2dece4bb/packages/1-framework/3-tooling/cli/scripts/record.ts#L118-L154","documentation":"Thrown by findMonorepoRoot in the CLI's record.ts script when walking up from the start directory to '/' without finding a pnpm-workspace.yaml file. The recording script depends on being run inside the Prisma Next monorepo (it resolves workspace paths relative to the root).","triggerScenarios":"Running `tsx scripts/record.ts` (or `npx tsx scripts/record.ts`) from a directory that is not inside the Prisma Next monorepo — e.g. the file was copied elsewhere, or invoked from /tmp or a non-workspace clone.","commonSituations":"Running the recording script in isolation outside the repo; the script's CLI_ROOT resolution produced an unexpected path; pnpm-workspace.yaml was renamed or deleted.","solutions":["Run the script from inside the Prisma Next monorepo (e.g. packages/1-framework/3-tooling/cli).","Ensure pnpm-workspace.yaml exists at the repository root.","If invoking programmatically, confirm the __dirname resolution points inside the repo."],"exampleFix":"// before: run from /tmp\ncd /tmp && tsx /path/to/record.ts  // throws\n// after: run from the cli package inside the monorepo\npnpm --filter @prisma/cli exec tsx scripts/record.ts","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nfunction hasMonorepoRoot(start: string): boolean {\n  let dir = start;\n  while (dir !== '/') {\n    if (existsSync(join(dir, 'pnpm-workspace.yaml'))) return true;\n    dir = dirname(dir);\n  }\n  return false;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run record.ts from within the Prisma Next monorepo.","Keep pnpm-workspace.yaml at the repository root."],"tags":["cli","record-script","monorepo","environment"],"backgroundTag":null,"analyzedSha":"a20d61fb6f095e636e6420ac2871c24f2dece4bb","analyzedAt":"2026-08-11T15:42:48.797Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}