{"record":{"id":"0f290fe2567b057a","repo":"aaif-goose/goose","slug":"goose-binary-is-only-supported-in-development-buil","errorCode":null,"errorMessage":"GOOSE_BINARY is only supported in development builds","messagePattern":"GOOSE_BINARY is only supported in development builds","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ui/desktop/src/gooseServe.ts","lineNumber":70,"sourceCode":"  startupDiagnosticsPath: string | null;\n  getStartupDiagnostics: () => GooseServeStartupDiagnostics | null;\n  recordStartupEvent: (name: string, details?: Record<string, unknown>) => void;\n}\n\nconst existingFile = (candidate: string): boolean => {\n  try {\n    return fs.existsSync(candidate) && fs.statSync(candidate).isFile();\n  } catch {\n    return false;\n  }\n};\n\nexport const findGooseBinaryPath = (options: FindGooseBinaryOptions = {}): string => {\n  const { isPackaged = false, resourcesPath } = options;\n  const pathFromEnv = process.env.GOOSE_BINARY;\n  if (pathFromEnv) {\n    if (isPackaged) {\n      throw new Error('GOOSE_BINARY is only supported in development builds');\n    }\n\n    const resolvedPath = path.resolve(pathFromEnv);\n    if (existingFile(resolvedPath)) {\n      return resolvedPath;\n    }\n    throw new Error(`Invalid GOOSE_BINARY path: ${pathFromEnv} (pwd is ${process.cwd()})`);\n  }\n\n  const binaryName = process.platform === 'win32' ? 'goose.exe' : 'goose';\n  const possiblePaths: string[] = [];\n\n  if (isPackaged && resourcesPath) {\n    possiblePaths.push(path.join(resourcesPath, 'bin', binaryName));\n    possiblePaths.push(path.join(resourcesPath, binaryName));\n  } else {\n    possiblePaths.push(\n      path.join(process.cwd(), 'src', 'bin', binaryName),","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/ui/desktop/src/gooseServe.ts#L52-L88","documentation":"Thrown by findGooseBinaryPath when the GOOSE_BINARY env var is set but the app reports isPackaged = true (production Electron build). The env override exists only for development builds so devs can point at a locally built goose binary; in packaged builds the binary must come from the bundled resources (resourcesPath/bin), and honoring an env var there would be a security/robustness risk.","triggerScenarios":"Launching an installed (packaged) goose desktop app from a shell or launcher environment that still exports GOOSE_BINARY; CI smoke tests that set GOOSE_BINARY globally then run a packaged build; a .env loader injecting the var into production.","commonSituations":"Developers packaging locally ('just build' / electron-builder) and running the artifact from the same terminal used for dev; CI environments with GOOSE_BINARY in the base image.","solutions":["Unset the variable for packaged runs: 'env -u GOOSE_BINARY /Applications/Goose.app/...' (or remove it from the launcher/service environment).","If you actually need a custom binary, run the development build (pnpm dev / electron .) where the override is honored.","For packaged builds, ensure the goose binary is bundled under resourcesPath so the fallback paths resolve."],"exampleFix":"// before\nif (pathFromEnv) {\n  if (isPackaged) {\n    throw new Error('GOOSE_BINARY is only supported in development builds');\n  }\n...\n\n// after (caller decides policy before invoking)\nif (process.env.GOOSE_BINARY && app.isPackaged) {\n  console.warn('Ignoring GOOSE_BINARY in packaged build; using bundled binary');\n  delete process.env.GOOSE_BINARY;\n}\nconst binaryPath = findGooseBinaryPath({ isPackaged: app.isPackaged, resourcesPath: process.resourcesPath });","handlingStrategy":"validation","validationCode":"// Scrub the env var for packaged runs before resolving the binary\nfunction gooseBinaryEnvForMode(isPackaged: boolean): string | undefined {\n  if (isPackaged && process.env.GOOSE_BINARY) {\n    console.warn('Ignoring GOOSE_BINARY in packaged build');\n    return undefined;\n  }\n  return process.env.GOOSE_BINARY;\n}","typeGuard":null,"tryCatchPattern":"try {\n  const binaryPath = findGooseBinaryPath({ isPackaged: app.isPackaged, resourcesPath: process.resourcesPath });\n} catch (error) {\n  if (/only supported in development builds/.test(String(error))) {\n    delete process.env.GOOSE_BINARY;\n    return findGooseBinaryPath({ isPackaged: app.isPackaged, resourcesPath: process.resourcesPath });\n  }\n  throw error;\n}","preventionTips":["Do not export GOOSE_BINARY in shells or CI base images used to run packaged builds.","Gate dev-only overrides on !app.isPackaged at the call site.","Ensure the packaged app bundles the binary so the env override is never needed in production."],"tags":["electron","environment","packaging","binary"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}