{"record":{"id":"b53f6f861ea7b5e7","repo":"emberjs/ember.js","slug":"the-global-context-for-glimmer-vm-was-not-set-you","errorCode":null,"errorMessage":"The global context for Glimmer VM was not set. You must set these global context functions to let Glimmer VM know how to accomplish certain operations. You can do this by importing `setGlobalContext` from `@glimmer/global-context`","messagePattern":"The global context for Glimmer VM was not set\\. You must set these global context functions to let Glimmer VM know how to accomplish certain operations\\. You can do this by importing `setGlobalContext` from `@glimmer/global-context`","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/@glimmer/global-context/index.ts","lineNumber":203,"sourceCode":"  toBool = context.toBool;\n  getProp = context.getProp;\n  setProp = context.setProp;\n  getPath = context.getPath;\n  setPath = context.setPath;\n  warnIfStyleNotTrusted = context.warnIfStyleNotTrusted;\n  assert = context.assert;\n  deprecate = context.deprecate;\n}\n\nexport let assertGlobalContextWasSet: (() => void) | undefined;\nexport let testOverrideGlobalContext:\n  | ((context: Partial<GlobalContext> | null) => GlobalContext | null)\n  | undefined;\n\nif (DEBUG) {\n  assertGlobalContextWasSet = () => {\n    if (!globalContextWasSet) {\n      throw new Error(\n        'The global context for Glimmer VM was not set. You must set these global context functions to let Glimmer VM know how to accomplish certain operations. You can do this by importing `setGlobalContext` from `@glimmer/global-context`'\n      );\n    }\n  };\n\n  testOverrideGlobalContext = (context: Partial<GlobalContext> | null) => {\n    let originalGlobalContext = globalContextWasSet\n      ? {\n          scheduleRevalidate,\n          scheduleDestroy,\n          scheduleDestroyed,\n          toIterator,\n          toBool,\n          getProp,\n          setProp,\n          getPath,\n          setPath,\n          warnIfStyleNotTrusted,","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/emberjs/ember.js/blob/26f97246a8bf2e28edf26ac3093da2e86c04ffc5/packages/@glimmer/global-context/index.ts#L185-L221","documentation":"Glimmer VM relies on host-provided operations (scheduling, logging, debugging) registered through `setGlobalContext()`. In DEBUG builds, `assertGlobalContextWasSet()` throws if any of these are needed before the host set the context. Without it, the VM cannot perform fundamental operations like scheduling revalidation.","triggerScenarios":"Rendering with Glimmer VM in a custom host application that never imported `@glimmer/global-context` and called `setGlobalContext()` before the first render/schedule; running Ember internals outside a full Ember app.","commonSituations":"Building a standalone Glimmer app or test harness from scratch; upgrading Glimmer and forgetting the new required global-context setup; test environments that render components without app bootstrapping.","solutions":["Import `setGlobalContext` from `@glimmer/global-context` and call it once at app startup before any rendering","At minimum provide `context.scheduleRevalidate`, which the VM requires","Use `@glimmer/global-context`'s test override helpers if a partial context is needed in tests","Check that your bootstrapping order puts setGlobalContext before the first `renderElement`/VM use"],"exampleFix":"// before\nimport { renderElement } from '@glimmer/runtime'; // renders before context set\nrenderElement(...);\n// after\nimport setGlobalContext from '@glimmer/global-context';\nsetGlobalContext({ scheduleRevalidate: () => {}, ... });\nrenderElement(...);","handlingStrategy":"validation","validationCode":"import setGlobalContext from '@glimmer/global-context';\n// bootstrap.js, before any render:\nsetGlobalContext({\n  scheduleRevalidate: () => {},\n  toIterator: undefined, // fill required entries per GlobalContext type\n  getDebugMethod: (name) => undefined,\n  assert: (cond, msg, { message }) => { if (!cond) throw new Error(message); },\n  deprecate: (msg) => {},\n  warn: (msg) => {}\n});","typeGuard":"function hasGlobalContext(host): host is Required<GlobalContext> { return typeof host.scheduleRevalidate === 'function'; }","tryCatchPattern":"try { renderTemplate(...); } catch (e) { if (/global context .* was not set/.test(e.message)) { setGlobalContext(defaultContext); renderTemplate(...); } else throw e; }","preventionTips":["Set the global context before any VM render or schedule call","Include setGlobalContext in app bootstrap, not lazily at first render","Type the context object as GlobalContext so missing fields fail typecheck"],"tags":["global-context","initialization","glimmer","missing-setup"],"backgroundTag":"global-context-not-set","analyzedSha":"26f97246a8bf2e28edf26ac3093da2e86c04ffc5","analyzedAt":"2026-09-01T05:01:28.182Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}