nocobase/nocobase · error

formatMissingManagedAppEnvMessage(${parsed.env}) (env not fo

Error message

formatMissingManagedAppEnvMessage(${parsed.env}) (env not found message)

What it means

`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.

Source

Thrown at packages/core/cli/src/commands/install.ts:1586

      !Install.toOptionalPromptString(flags['root-nickname']) &&
      !Install.toOptionalPromptString(resumePreset.rootPreset.rootNickname)
    ) {
      missing.push('--root-nickname');
    }
    return missing;
  }

  private async resolveResumePresetValues(
    parsed: InstallParsedFlags & DownloadParsedFlags,
    yes: boolean,
  ): Promise<ResumePresetValues | undefined> {
    if (!parsed.resume) {
      return undefined;
    }

    const env = await getEnv(parsed.env, { scope: resolveDefaultConfigScope() });
    if (!env) {
      throw new Error(formatMissingManagedAppEnvMessage(parsed.env));
    }

    const resumePreset = Install.buildResumePresetValues(env);

    if (yes) {
      const missingFlags = Install.buildResumeMissingYesFlags(parsed, resumePreset);
      if (missingFlags.length > 0) {
        throw new Error(
          [
            `Cannot continue setup for "${env.name}" in non-interactive resume mode yet.`,
            `These setup-only flags are not saved in the env config: ${missingFlags.join(', ')}`,
            `Run \`nb init --ui --env ${env.name} --resume\` without \`--yes\`, or pass those flags again.`,
          ].join('\n'),
        );
      }
    }

    return resumePreset;

View on GitHub (pinned to fa42722fef)

Solutions

  1. Run `nb env list` (or `nb app list`) to see existing env names and correct the --env value
  2. If the env never existed, drop --resume and run `nb init --ui --env <name>` to create it fresh
  3. If the config was lost (new machine, cleaned CLI home), recreate the env config or restore it from backup before resuming
  4. Check the config scope (`resolveDefaultConfigScope`) if you use a custom NOCOBASE_CLI_HOME — the env may exist in a different scope

Example fix

// before
nb init --ui --env prod --resume
// error: env not found
// after
nb env list                      # discover the real name
cp -r ~/.nocobase-different-home ~/.nocobase   # if configs live in another CLI home
nb init --ui --env prod --resume
Defensive patterns

Strategy: validation

Validate before calling

# Confirm the env exists before attempting resume:
nb env list | grep -qx "$ENV_NAME" || { echo "env '$ENV_NAME' does not exist"; exit 1; }

Try / catch

try {
  await nb(['init','--ui','--env',envName,'--resume']);
} catch (err) {
  if (/no .*env|env .*not found|managed app env/i.test(err.message)) {
    console.error(`Env "${envName}" is missing; create it with: nb init --ui --env ${envName}`);
  }
  throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of nocobase/nocobase@fa42722fef (2026-09-01). Data as JSON: /api/errors/71dac8fb99c6ad72. Report an issue: GitHub.