{"record":{"id":"7f97de5c75a6a095","repo":"mastra-ai/mastra","slug":"no-project-specified-pass-project-name-slug-id","errorCode":null,"errorMessage":"No project specified. Pass --project <name|slug|id>, set MASTRA_PROJECT_ID, or run from a directory with a linked .mastra-project.json.","messagePattern":"No project specified\\. Pass --project <name\\|slug\\|id>, set MASTRA_PROJECT_ID, or run from a directory with a linked \\.mastra-project\\.json\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/env/resolve-project.ts","lineNumber":29,"sourceCode":"export async function resolveProject(token: string, orgId: string, projectArg?: string): Promise<Project> {\n  const projects = await fetchProjects(token, orgId);\n\n  const wanted = process.env.MASTRA_PROJECT_ID ?? projectArg;\n  if (wanted) {\n    const project = projects.find(proj => proj.id === wanted || proj.name === wanted || proj.slug === wanted);\n    if (!project) {\n      throw new Error(`Project not found: ${wanted}`);\n    }\n    return project;\n  }\n\n  const config = await loadProjectConfig(process.cwd());\n  if (config?.projectId) {\n    const project = projects.find(proj => proj.id === config.projectId);\n    if (project) return project;\n  }\n\n  throw new Error(\n    'No project specified. Pass --project <name|slug|id>, set MASTRA_PROJECT_ID, or run from a directory with a linked .mastra-project.json.',\n  );\n}\n","sourceCodeStart":11,"sourceCodeEnd":33,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/env/resolve-project.ts#L11-L33","documentation":"Thrown by `resolveProject` when no project identifier is available at all: no --project flag, no MASTRA_PROJECT_ID env var, and the current directory has no linked .mastra-project.json (or its projectId doesn't match a project). The CLI refuses to guess which Mastra Cloud project the env command should target.","triggerScenarios":"Running `mastra env ...` outside a linked project directory, in a fresh clone where .mastra-project.json was never created or is gitignored, with MASTRA_PROJECT_ID unset, and without passing --project.","commonSituations":"Running the command from the repo root instead of the directory linked to Mastra Cloud; CI environment missing the MASTRA_PROJECT_ID secret; .mastra-project.json deleted or ignored by .gitignore; teammate never ran the link step.","solutions":["Pass the project explicitly: `mastra env vars pull --project <name|slug|id>`","Set MASTRA_PROJECT_ID in the environment (or CI secrets) to the project id","Link the directory to the project so .mastra-project.json is created (mastra project link / init flow), or copy a teammate's file","Run the command from the directory that already has .mastra-project.json","For CI, commit .mastra-project.json or inject MASTRA_PROJECT_ID in the workflow"],"exampleFix":"// before\nmastra env vars pull\n// Error: No project specified...\n// after\nmastra env vars pull --project my-project\n// or: export MASTRA_PROJECT_ID=prj_1234","handlingStrategy":"validation","validationCode":"import { existsSync, readFileSync } from 'node:fs';\nconst linked = existsSync('.mastra-project.json')\n  ? JSON.parse(readFileSync('.mastra-project.json', 'utf8'))\n  : null;\nif (!linked?.projectId && !process.env.MASTRA_PROJECT_ID && !process.argv.includes('--project')) {\n  throw new Error('No Mastra project target: pass --project, set MASTRA_PROJECT_ID, or run inside a linked directory (.mastra-project.json).');\n}","typeGuard":"function hasProjectTarget(args: { project?: string }, env: NodeJS.ProcessEnv, linkedConfigFile: unknown): boolean {\n  const linked = linkedConfigFile as { projectId?: string } | null;\n  return Boolean(args.project || env.MASTRA_PROJECT_ID || linked?.projectId);\n}","tryCatchPattern":"try {\n  await runEnvCommand(argv);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('No project specified')) {\n    console.error(`${err.message}\\nTip: run \\`mastra project link\\` in this directory or export MASTRA_PROJECT_ID in CI.`);\n    process.exitCode = 1;\n    return;\n  }\n  throw err;\n}","preventionTips":["Run `mastra project link` once per project directory and keep .mastra-project.json out of .gitignore (it contains no secrets)","Set MASTRA_PROJECT_ID in CI secrets so headless runs never need flags","Document in team onboarding that env commands must run from the linked directory","Prefer --project in scripts to make them directory-independent"],"tags":["cli","config","missing-argument","mastra-cloud"],"backgroundTag":"missing-required-argument","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}