{"record":{"id":"e3082ca46238b812","repo":"actualbudget/actual","slug":"the-environment-variable-lootcorescript-is-not-d","errorCode":null,"errorMessage":"The environment variable `lootCoreScript` is not defined. Please define it to point to the server bundle.","messagePattern":"The environment variable `lootCoreScript` is not defined\\. Please define it to point to the server bundle\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/desktop-electron/server.ts","lineNumber":7,"sourceCode":"import { retry as promiseRetry } from './retry';\n\nconst BACKEND_IMPORT_MAX_RETRIES = 30;\n\nconst lazyLoadBackend = async (isDev: boolean) => {\n  if (process.env.lootCoreScript === undefined) {\n    throw new Error(\n      'The environment variable `lootCoreScript` is not defined. Please define it to point to the server bundle.',\n    );\n  }\n\n  try {\n    // These retries are primarily for dev mode, where we watch for changes in loot-core\n    // In a packaged build this should always work the first time.\n    const bundle = await promiseRetry(\n      async (retry, number) => {\n        try {\n          return await import(process.env.lootCoreScript!);\n        } catch (error) {\n          console.info(\n            `Loading server bundle: Attempt ${number} of ${BACKEND_IMPORT_MAX_RETRIES}`,\n          );\n\n          retry(error);\n        }","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/desktop-electron/server.ts#L1-L25","documentation":"`lazyLoadBackend` in the Electron main process refuses to start unless the `lootCoreScript` environment variable points at the compiled loot-core server bundle. It is undefined here, so the app cannot locate the backend to import and throws immediately.","triggerScenarios":"Launching the packaged Electron app (isDev = false) when the main process was started without `process.env.lootCoreScript` set to the path of the loot-core server bundle.","commonSituations":"Running the electron binary directly instead of via the build scripts that set the env var; a broken packaging step that failed to emit or reference the server bundle; custom dev harnesses that only set the var in dev mode.","solutions":["Set the `lootCoreScript` env var to the absolute path of the built loot-core server bundle before launching the Electron main process","Rebuild the app with the official packaging scripts so the bundle path is injected","Check the electron-builder/packaging config to ensure `lootCoreScript` is included in the packaged app's environment"],"exampleFix":"// before\nyarn electron packages/desktop-electron\n// after\nlootCoreScript=./packages/loot-core/lib-dist/app.node.js yarn electron packages/desktop-electron","handlingStrategy":"validation","validationCode":"if (typeof process.env.lootCoreScript !== 'string' || !process.env.lootCoreScript) {\n  throw new Error('Set lootCoreScript to the loot-core server bundle path before starting electron.');\n}\nimport fs from 'fs';\nif (!fs.existsSync(process.env.lootCoreScript)) {\n  throw new Error(`lootCoreScript bundle missing at ${process.env.lootCoreScript}; build loot-core first.`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always launch the Electron app via its documented scripts, which set lootCoreScript","Add a prelaunch check that the env var exists and the bundle file is present","Fail fast in CI packaging if the server bundle artifact is missing"],"tags":["electron","env-var","startup"],"backgroundTag":"missing-env-var","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}