{"record":{"id":"71dac8fb99c6ad72","repo":"nocobase/nocobase","slug":"formatmissingmanagedappenvmessage-parsed-env","errorCode":null,"errorMessage":"formatMissingManagedAppEnvMessage(${parsed.env}) (env not found message)","messagePattern":"formatMissingManagedAppEnvMessage\\((.+?)\\) \\(env not found message\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/cli/src/commands/install.ts","lineNumber":1586,"sourceCode":"      !Install.toOptionalPromptString(flags['root-nickname']) &&\n      !Install.toOptionalPromptString(resumePreset.rootPreset.rootNickname)\n    ) {\n      missing.push('--root-nickname');\n    }\n    return missing;\n  }\n\n  private async resolveResumePresetValues(\n    parsed: InstallParsedFlags & DownloadParsedFlags,\n    yes: boolean,\n  ): Promise<ResumePresetValues | undefined> {\n    if (!parsed.resume) {\n      return undefined;\n    }\n\n    const env = await getEnv(parsed.env, { scope: resolveDefaultConfigScope() });\n    if (!env) {\n      throw new Error(formatMissingManagedAppEnvMessage(parsed.env));\n    }\n\n    const resumePreset = Install.buildResumePresetValues(env);\n\n    if (yes) {\n      const missingFlags = Install.buildResumeMissingYesFlags(parsed, resumePreset);\n      if (missingFlags.length > 0) {\n        throw new Error(\n          [\n            `Cannot continue setup for \"${env.name}\" in non-interactive resume mode yet.`,\n            `These setup-only flags are not saved in the env config: ${missingFlags.join(', ')}`,\n            `Run \\`nb init --ui --env ${env.name} --resume\\` without \\`--yes\\`, or pass those flags again.`,\n          ].join('\\n'),\n        );\n      }\n    }\n\n    return resumePreset;","sourceCodeStart":1568,"sourceCodeEnd":1604,"githubUrl":"https://github.com/nocobase/nocobase/blob/fa42722fefe44265490dff2c27d79e2882bce4fa/packages/core/cli/src/commands/install.ts#L1568-L1604","documentation":"`nb init --resume --env <name>` requires that the named env already exists in the CLI's env store. Install calls getEnv() and, when it returns undefined, throws formatMissingManagedAppEnvMessage(parsed.env) — a message explaining that there is no managed app env with that name and how to list/create envs. It stops the resume attempt before any partial setup is performed against a nonexistent env.","triggerScenarios":"Running `nb init --ui --env <name> --resume` where no env named <name> was previously created (getEnv returns undefined at install.ts:1584); also after the env config was removed (`nb env remove`) or the CLI home/config scope changed so the store no longer contains it.","commonSituations":"Typo in the env name (`--env pro` vs `prod`); resuming on a different machine or after wiping ~/.nocobase config; env deleted by a cleanup script; using --resume for a first-time install that never got far enough to persist the env.","solutions":["Run `nb env list` (or `nb app list`) to see existing env names and correct the --env value","If the env never existed, drop --resume and run `nb init --ui --env <name>` to create it fresh","If the config was lost (new machine, cleaned CLI home), recreate the env config or restore it from backup before resuming","Check the config scope (`resolveDefaultConfigScope`) if you use a custom NOCOBASE_CLI_HOME — the env may exist in a different scope"],"exampleFix":"// before\nnb init --ui --env prod --resume\n// error: env not found\n// after\nnb env list                      # discover the real name\ncp -r ~/.nocobase-different-home ~/.nocobase   # if configs live in another CLI home\nnb init --ui --env prod --resume","handlingStrategy":"validation","validationCode":"# Confirm the env exists before attempting resume:\nnb env list | grep -qx \"$ENV_NAME\" || { echo \"env '$ENV_NAME' does not exist\"; exit 1; }","typeGuard":null,"tryCatchPattern":"try {\n  await nb(['init','--ui','--env',envName,'--resume']);\n} catch (err) {\n  if (/no .*env|env .*not found|managed app env/i.test(err.message)) {\n    console.error(`Env \"${envName}\" is missing; create it with: nb init --ui --env ${envName}`);\n  }\n  throw err;\n}","preventionTips":["Verify env names with `nb env list` before scripting resume commands","Keep CLI home (~/.nocobase) backed up or provisioned consistently across machines/CI","Do not remove envs referenced by automation scripts without updating those scripts","Only use --resume for envs that previously existed; omit it for first-time installs"],"tags":["cli","install","env","resume","missing-config"],"backgroundTag":"missing-env-config","analyzedSha":"fa42722fefe44265490dff2c27d79e2882bce4fa","analyzedAt":"2026-09-01T00:54:31.202Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}