{"record":{"id":"ab6b529ebfdd0e01","repo":"nocobase/nocobase","slug":"env-env-envname-is-missing-a-base-url","errorCode":null,"errorMessage":"${env ? `Env \"${envName}\" is missing a base URL.` : `Env \"${envName}\" is not configured. Run `nb init --ui --env ${envName}` first.`}\n${env ? `Update env \"${envName}\" with `nb env update ${envName} --api-base-url <url>` first.` : ''}","messagePattern":"(.+?)\" is missing a base URL\\.` : `Env \"(.+?)\" is not configured\\. Run `nb init --ui --env (.+?)` first\\.`\\}\n(.+?)\" with `nb env update (.+?) --api-base-url <url>` first\\.` : ''\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/cli/src/lib/bootstrap.ts","lineNumber":476,"sourceCode":"  role?: string;\n  configFile: string;\n  verbose?: boolean;\n  scope?: CliHomeScope;\n  quiet?: boolean;\n}) {\n  setVerboseMode(Boolean(options.verbose));\n  const envName = options.envName ?? (await getCurrentEnvName({ scope: options.scope }));\n  const env = await getEnv(envName, { scope: options.scope });\n  const baseUrl = options.baseUrl ?? env?.baseUrl;\n  const token = await resolveAccessToken({\n    envName,\n    baseUrl,\n    token: options.token,\n    scope: options.scope,\n  });\n\n  if (!baseUrl) {\n    throw new Error(\n      [\n        env\n          ? `Env \"${envName}\" is missing a base URL.`\n          : `Env \"${envName}\" is not configured. Run \\`nb init --ui --env ${envName}\\` first.`,\n        env ? `Update env \"${envName}\" with \\`nb env update ${envName} --api-base-url <url>\\` first.` : '',\n      ]\n        .filter(Boolean)\n        .join('\\n'),\n    );\n  }\n\n  if (!options.quiet) {\n    updateTask('Loading command runtime...');\n  }\n  try {\n    if (!options.quiet) {\n      printVerbose(`Runtime source: ${baseUrl}`);\n    }","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/nocobase/nocobase/blob/fa42722fefe44265490dff2c27d79e2882bce4fa/packages/core/cli/src/lib/bootstrap.ts#L458-L494","documentation":"updateEnvRuntime() refreshes the stored runtime metadata for an env by fetching the swagger schema. Before making any request it requires a base URL (from options or the saved env). If none exists, it throws an error telling the user the env is either missing a base URL (env exists) or not configured at all (no env record), with exact `nb env update`/`nb init` commands to fix it.","triggerScenarios":"Calling updateEnvRuntime (via the `runtime` command) with options.baseUrl unset while the target env record is absent or has no baseUrl field — e.g. an env created with only a token, or a wrong --env name pointing to a nonexistent env.","commonSituations":"User created an env via `nb env add <name>` without --api-base-url; typo in the `--env` flag selecting an unconfigured env; config file edited or truncated by hand; migrating config to a new machine where envs were not carried over.","solutions":["Set the base URL for the env: `nb env update <envName> --api-base-url <url>`.","If the env does not exist at all, run `nb init --ui --env <envName>` to configure it.","Verify the env name and saved settings with `nb env list` before retrying."],"exampleFix":"// before\nnb runtime --env staging  # Env \"staging\" is not configured...\n// after\nnb env update staging --api-base-url https://staging.example.com\nnb runtime --env staging","handlingStrategy":"validation","validationCode":"// verify the env has a baseUrl before invoking the runtime command\nconst listed = execSync(`nb env list`, { encoding: 'utf8' });\nif (!listed.includes(envName)) {\n  throw new Error(`Env \"${envName}\" does not exist. Run \\`nb init --ui --env ${envName}\\` first.`);\n}","typeGuard":"function envIsConfigured(env: { baseUrl?: string } | null | undefined): env is { baseUrl: string } & Record<string, unknown> {\n  return !!env && typeof env.baseUrl === 'string' && /^https?:\\/\\//.test(env.baseUrl);\n}","tryCatchPattern":"try {\n  execSync(`nb runtime --env ${envName}`, { stdio: 'inherit' });\n} catch (err) {\n  if (String(err).includes('is missing a base URL')) {\n    execSync(`nb env update ${envName} --api-base-url ${process.env.NB_BASE_URL}`, { stdio: 'inherit' });\n    execSync(`nb runtime --env ${envName}`, { stdio: 'inherit' });\n  } else throw err;\n}","preventionTips":["Always create envs with `--api-base-url` set, not just a token.","Double-check the `--env` flag value against `nb env list` — typos resolve to an unconfigured env.","After hand-editing or syncing CLI config between machines, run `nb env list` to validate each env."],"tags":["cli","configuration","env","base-url"],"backgroundTag":"missing-env-config","analyzedSha":"fa42722fefe44265490dff2c27d79e2882bce4fa","analyzedAt":"2026-09-01T00:54:31.202Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}