{"record":{"id":"eaf8dcaf2f43f5e8","repo":"aaif-goose/goose","slug":"goose-binary-package-pkg-is-not-installed-set","errorCode":null,"errorMessage":"goose binary package ${pkg} is not installed. Set GOOSE_BINARY or install the native package.","messagePattern":"goose binary package (.+?) is not installed\\. Set GOOSE_BINARY or install the native package\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"ui/sdk/src/resolve-binary.ts","lineNumber":39,"sourceCode":"export function resolveGooseBinary(): string {\n  const envBinary = process.env.GOOSE_BINARY;\n  if (envBinary) return envBinary;\n\n  const key = `${process.platform}-${process.arch}`;\n  const pkg = PLATFORMS[key];\n  if (!pkg) {\n    throw new Error(\n      `No goose binary available for ${key}. Set GOOSE_BINARY to the path of a goose binary.`,\n    );\n  }\n\n  try {\n    const require = createRequire(import.meta.url);\n    const pkgDir = dirname(require.resolve(`${pkg}/package.json`));\n    const binName = process.platform === \"win32\" ? \"goose.exe\" : \"goose\";\n    return join(pkgDir, \"bin\", binName);\n  } catch {\n    throw new Error(\n      `goose binary package ${pkg} is not installed. Set GOOSE_BINARY or install the native package.`,\n    );\n  }\n}\n","sourceCodeStart":21,"sourceCodeEnd":44,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/ui/sdk/src/resolve-binary.ts#L21-L44","documentation":"The platform key was found in PLATFORMS, but require.resolve(`${pkg}/package.json`) failed — the optional dependency @aaif/goose-binary-<platform>-<arch> is not installed in node_modules. npm skips failed optionalDependencies silently (common when the platform-specific tarball is missing or was pruned), so the SDK only discovers the absence at resolve time.","triggerScenarios":"npm/pnpm/yarn install with --no-optional or --omit=optional; npm bug where optional deps are dropped from the lockfile; package-lock generated on one platform then installed on another with the tarball 404; manually pruned node_modules; pnpm hoisting settings hiding the package.","commonSituations":"CI images caching node_modules across platform changes; Docker multi-arch builds sharing a lockfile; npm ERESOLVE recoveries that silently drop optionals; corporate registries mirroring only some platform tarballs.","solutions":["Set GOOSE_BINARY to an existing binary path — fastest unblock, skips the package resolution entirely","Reinstall with optional deps enabled: rm -rf node_modules package-lock.json && npm install (or verify pnpm/yarn optional config)","Confirm the package exists: npm ls @aaif/goose-binary-<platform>-<arch> and check the registry has the tarball for your platform","For pnpm, ensure optionalDependencies are not filtered in .npmrc"],"exampleFix":"# before\nnpm install --omit=optional\nnode app.js # throws: goose binary package ... is not installed\n# after\nexport GOOSE_BINARY=/usr/local/bin/goose\nnode app.js\n# or\nnpm install # with optionals enabled","handlingStrategy":"fallback","validationCode":"// At install time (Dockerfile/CI):\n// npm ls @aaif/goose-binary-linux-x64 || echo 'set GOOSE_BINARY or fix optionals'\nimport { existsSync } from 'fs';\nif (!process.env.GOOSE_BINARY) {\n  // confirm node_modules actually contains the optional package before shipping\n}","typeGuard":"const canResolveNativeBinary = (): boolean => {\n  if (process.env.GOOSE_BINARY) return true;\n  const pkg = PLATFORMS[`${process.platform}-${process.arch}`];\n  if (!pkg) return false;\n  try { createRequire(import.meta.url).resolve(`${pkg}/package.json`); return true; }\n  catch { return false; }\n};","tryCatchPattern":"let bin: string;\ntry {\n  bin = resolveGooseBinary();\n} catch (e) {\n  if (String(e).includes('not installed')) {\n    bin = process.env.GOOSE_BINARY!; // caller must guarantee it is set as fallback\n  } else throw e;\n}","preventionTips":["Never install with --no-optional/--omit=optional for apps needing the binary","Run a postinstall assertion that resolveGooseBinary() succeeds in CI","Bake GOOSE_BINARY into container images as a safety net"],"tags":["npm","optional-dependencies","binary","sdk","installation"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}