{"record":{"id":"ed43ec80d054cf06","repo":"angular/angular-cli","slug":"could-not-find-global-workspace","errorCode":null,"errorMessage":"Could not find global workspace","messagePattern":"Could not find global workspace","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular/cli/src/utilities/completion.ts","lineNumber":110,"sourceCode":"    );\n  }\n\n  // Save configuration to remember that the user was prompted.\n  await setCompletionConfig({ ...completionConfig, prompted: true });\n\n  return undefined;\n}\n\nasync function getCompletionConfig(): Promise<CompletionConfig | undefined> {\n  const wksp = await getWorkspace('global');\n\n  return wksp?.getCli()?.['completion'];\n}\n\nasync function setCompletionConfig(config: CompletionConfig): Promise<void> {\n  const wksp = await getWorkspace('global');\n  if (!wksp) {\n    throw new Error(`Could not find global workspace`);\n  }\n\n  wksp.extensions['cli'] ??= {};\n  const cli = wksp.extensions['cli'];\n  if (!json.isJsonObject(cli)) {\n    throw new Error(\n      `Invalid config found at ${wksp.filePath}. \\`extensions.cli\\` should be an object.`,\n    );\n  }\n  cli.completion = config as json.JsonObject;\n  await wksp.save();\n}\n\nasync function shouldPromptForAutocompletionSetup(\n  command: string,\n  config?: CompletionConfig,\n): Promise<boolean> {\n  // Force whether or not to prompt for autocomplete to give an easy path for e2e testing to skip.","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/utilities/completion.ts#L92-L128","documentation":"Thrown by setCompletionConfig in the Angular CLI completion utilities when getWorkspace('global') returns undefined, meaning the global Angular workspace/configuration file could not be located or loaded. The function needs it to persist the `cli.completion` setting that records whether the user was prompted for autocompletion setup.","triggerScenarios":"considerSettingUpAutocompletion reaching the config-save step in an environment where no global config file exists or fails to load (e.g. unreadable/missing ~/.angular-config or equivalent, HOME not resolvable, or workspace creation returning undefined).","commonSituations":"Running the CLI in containers/CI with no home directory or a read-only HOME, corrupted global Angular config causing getWorkspace to yield undefined, sandboxed environments, or unusual XDG_CONFIG_HOME/HOME setups.","solutions":["Ensure a valid global Angular config exists: run any ng command once or create ~/.angular-config (or the path from NG_CLI_ANALYTICS/global workspace resolution) with valid JSON.","Verify HOME (and XDG_CONFIG_HOME if used) is set and writable; fix the environment in CI/containers.","Inspect the global config file for corruption/parse errors and repair or delete it so it can be regenerated.","Guard the call site: wrap setCompletionConfig in try/catch and log a warning instead of failing the command, since completion setup is non-essential."],"exampleFix":"// before\nawait setCompletionConfig({ ...completionConfig, prompted: true });\n// after\ntry {\n  await setCompletionConfig({ ...completionConfig, prompted: true });\n} catch (err) {\n  logger.warn(`Could not save completion config: ${(err as Error).message}`);\n}","handlingStrategy":"try-catch","validationCode":"import { getWorkspace } from './utilities/workspace';\nconst wksp = await getWorkspace('global');\nif (!wksp) {\n  logger.warn('No global Angular workspace; skipping completion setup');\n  return;\n}","typeGuard":"function isWorkspace(v: unknown): v is { filePath: string; extensions: Record<string, unknown>; save(): Promise<void> } {\n  return typeof v === 'object' && v !== null && 'filePath' in v && 'save' in v;\n}","tryCatchPattern":"try {\n  await setCompletionConfig(config);\n} catch (err) {\n  if ((err as Error).message === 'Could not find global workspace') {\n    logger.warn('Completion config not saved: global Angular config missing');\n  } else throw err;\n}","preventionTips":["Run `ng` once interactively to create the global config before scripted/CI use","Ensure HOME is set and writable in containers and CI images","Keep ~/.angular-config valid JSON; avoid hand edits that break parsing","Treat completion setup as best-effort and never let it fail the main command"],"tags":["angular-cli","completion","global-config","filesystem"],"backgroundTag":"missing-global-workspace","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}