{"record":{"id":"b4273ea0bdd423dc","repo":"mastra-ai/mastra","slug":"cannot-combine-an-environment-argument-with-shar","errorCode":null,"errorMessage":"Cannot combine an environment argument with --shared. Pick one scope.","messagePattern":"Cannot combine an environment argument with --shared\\. Pick one scope\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/db/db.ts","lineNumber":304,"sourceCode":"  return kind;\n}\n\nasync function createDatabaseAction(\n  envArg: string | undefined,\n  options: {\n    project?: string;\n    kind: string;\n    name?: string;\n    region?: string;\n    shared?: boolean;\n    wait: boolean;\n    json?: boolean;\n  },\n) {\n  const kind = parseKind(options.kind);\n\n  if (envArg && options.shared) {\n    throw new Error('Cannot combine an environment argument with --shared. Pick one scope.');\n  }\n\n  const token = await getToken();\n  const { orgId } = await resolveCurrentOrg(token);\n  const project = await resolveProject(token, orgId, options.project);\n\n  const environment = options.shared\n    ? undefined\n    : envArg\n      ? await findEnvironment(token, orgId, project, envArg)\n      : await resolveDefaultEnvironment(token, orgId, project, { json: options.json });\n\n  if (environment && options.region && !options.json) {\n    console.info(`Note: --region is ignored for environment-scoped databases; the environment's region is used.`);\n  }\n\n  await createDatabase({\n    token,","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/db/db.ts#L286-L322","documentation":"createDatabaseAction rejects mutually exclusive scoping inputs: a positional environment argument (environment-scoped database) and the --shared flag (project-scoped database). Exactly one scope must be chosen, so the CLI fails fast instead of guessing.","triggerScenarios":"`mastra env db create <env> --shared --kind ...` — an environment positional is present while --shared is set.","commonSituations":"Scripting the command with both a default env arg and a --shared flag enabled in config, or misunderstanding that --shared replaces (not augments) the environment argument.","solutions":["Drop the environment argument to create a project-scoped shared database: `mastra env db create --shared --kind turso`.","Or drop --shared to create an environment-scoped database: `mastra env db create <env> --kind turso`.","In scripts, make the scope conditional so only one of the two is ever passed."],"exampleFix":"// before\nmastra env db create production --shared --kind turso\n// after\nmastra env db create --shared --kind turso  # or: mastra env db create production --kind turso","handlingStrategy":"validation","validationCode":"if (envArg && shared) {\n  throw new Error('Pass either an environment argument or --shared, not both.');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await createDatabase(envArg, { shared, kind });\n} catch (e) {\n  if (/Cannot combine an environment argument with --shared/.test((e as Error).message)) {\n    console.error('Choose one scope: drop the env arg (shared) or drop --shared (env-scoped).');\n  }\n}","preventionTips":["Model scope in scripts as a single enum ('env' | 'shared') so both can't be set.","Review CLI wrappers that merge user args with config defaults — --shared defaults to false, don't force it.","Remember --shared replaces the environment argument; it does not modify it."],"tags":["cli","argument-conflict","validation"],"backgroundTag":"mutually-exclusive-arguments","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}