{"record":{"id":"7cf90ed27ae7251a","repo":"gatsbyjs/gatsby","slug":"target-platform-arch-for-functions-execution-fu","errorCode":null,"errorMessage":"Target platform/arch for functions execution (${functionsTarget.platform}/${functionsTarget.arch}) is not supported.","messagePattern":"Target platform/arch for functions execution \\((.+?)/(.+?)\\) is not supported\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/gatsby/src/schema/graphql-engine/bundle-webpack.ts","lineNumber":107,"sourceCode":"  version: string,\n  functionsTarget: IPlatformAndArch\n): string | undefined {\n  // Read lmdb's package.json, go through its optional depedencies and validate if there's a prebuilt lmdb module with a compatible binary to our platform and arch\n  let packageJson: PackageJson\n  try {\n    const modulePath = path\n      .dirname(slash(require.resolve(`lmdb`)))\n      .replace(`/dist`, ``)\n    const packageJsonPath = path.join(modulePath, `package.json`)\n    packageJson = JSON.parse(fs.readFileSync(packageJsonPath, `utf-8`))\n  } catch (e) {\n    // If we fail to read lmdb's package.json there's bigger problems here so just skip installation\n    return undefined\n  }\n  // If there's no lmdb prebuilt package for our arch/platform listed as optional dep no point in trying to install it\n  const { optionalDependencies = {} } = packageJson\n  if (!Object.keys(optionalDependencies).find(p => p === lmdbPackageName)) {\n    throw new Error(\n      `Target platform/arch for functions execution (${functionsTarget.platform}/${functionsTarget.arch}) is not supported.`\n    )\n  }\n  return getPackageLocationFromRequireContext(\n    slash(require.resolve(`lmdb`)),\n    lmdbPackageName,\n    version\n  )\n}\n\nfunction getPackageLocationFromRequireContext(\n  location: string,\n  packageName: string,\n  packageVersion?: string\n): string | undefined {\n  try {\n    const requireId = `${packageName}/package.json`\n    const locationRequire = mod.createRequire(location)","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby/src/schema/graphql-engine/bundle-webpack.ts#L89-L125","documentation":"When bundling the query/engine for a functions (DSG/SSR) target platform/arch, Gatsby checks whether lmdb ships a prebuilt binary for that target by looking up the platform-specific lmdb package name in lmdb's optionalDependencies. If the target platform/arch does not match any prebuilt package, it throws because the engine cannot use lmdb storage there. This is the 'unsupported target' guard before any install attempt.","triggerScenarios":"Building functions for a cross target (e.g. building on macOS/Windows for a linux deployment, or an exotic arch like armv7/s390x) where functionsTarget.platform/arch produces an lmdbPackageName that is NOT a key of lmdb's optionalDependencies. The throw happens in checkIfNeedToInstallMissingLmdb before installMissing runs.","commonSituations":"Cross-compiling functions for a deployment target lmdb does not prebuild (some musl/alpine variants, uncommon arches); using --functions-platform/--functions-arch flags with an unsupported value; lmdb version in the tree that dropped support for the requested target.","solutions":["Check supported lmdb prebuilt targets and choose a functions-platform/arch that has a prebuild (commonly linux x64/arm64, darwin x64/arm64, win32 x64).","Drop the --functions-platform/--functions-arch flags so Gatsby builds for the host you will actually run on.","Upgrade/downgrade lmdb (via overrides/resolutions) to a version that ships a binary for your target.","For alpine/musl, ensure the musl-specific lmdb prebuild package is available or switch to a glibc-based image."],"exampleFix":"# before\ngatsby build --functions-platform=linux --functions-arch=armv7 # unsupported\n# after\ngatsby build --functions-platform=linux --functions-arch=arm64","handlingStrategy":"validation","validationCode":"// Validate the target before invoking a cross-build.\nconst SUPPORTED = new Set(['linux-x64','linux-arm64','darwin-x64','darwin-arm64','win32-x64'])\nfunction checkFunctionsTarget(platform, arch) {\n  if (!SUPPORTED.has(`${platform}-${arch}`)) {\n    throw new Error(`Unsupported functions target ${platform}/${arch}; pick from ${[...SUPPORTED].join(', ')}`)\n  }\n}","typeGuard":"function isSupportedLmdbTarget(platform, arch) {\n  const lmdb = require('lmdb/package.json')\n  return Object.keys(lmdb.optionalDependencies || {})\n    .some(p => p.includes(`@lmdb/${platform}-${arch}`) || p.includes(`${platform}-${arch}`))\n}","tryCatchPattern":null,"preventionTips":["Build functions for a target that has an lmdb prebuild (linux/darwin/win32 on x64/arm64).","Avoid exotic arches; if needed, ensure lmdb prebuilds exist.","Pin lmdb to a version that supports your target."],"tags":["bundle-webpack","lmdb","functions","cross-compile","native-binary"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}