gatsbyjs/gatsby · error · Error

Target platform/arch for functions execution (${functionsTar

Error message

Target platform/arch for functions execution (${functionsTarget.platform}/${functionsTarget.arch}) is not supported.

What it means

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.

Source

Thrown at packages/gatsby/src/schema/graphql-engine/bundle-webpack.ts:107

  version: string,
  functionsTarget: IPlatformAndArch
): string | undefined {
  // 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
  let packageJson: PackageJson
  try {
    const modulePath = path
      .dirname(slash(require.resolve(`lmdb`)))
      .replace(`/dist`, ``)
    const packageJsonPath = path.join(modulePath, `package.json`)
    packageJson = JSON.parse(fs.readFileSync(packageJsonPath, `utf-8`))
  } catch (e) {
    // If we fail to read lmdb's package.json there's bigger problems here so just skip installation
    return undefined
  }
  // If there's no lmdb prebuilt package for our arch/platform listed as optional dep no point in trying to install it
  const { optionalDependencies = {} } = packageJson
  if (!Object.keys(optionalDependencies).find(p => p === lmdbPackageName)) {
    throw new Error(
      `Target platform/arch for functions execution (${functionsTarget.platform}/${functionsTarget.arch}) is not supported.`
    )
  }
  return getPackageLocationFromRequireContext(
    slash(require.resolve(`lmdb`)),
    lmdbPackageName,
    version
  )
}

function getPackageLocationFromRequireContext(
  location: string,
  packageName: string,
  packageVersion?: string
): string | undefined {
  try {
    const requireId = `${packageName}/package.json`
    const locationRequire = mod.createRequire(location)

View on GitHub (pinned to 8b06340921)

Solutions

  1. Check supported lmdb prebuilt targets and choose a functions-platform/arch that has a prebuild (commonly linux x64/arm64, darwin x64/arm64, win32 x64).
  2. Drop the --functions-platform/--functions-arch flags so Gatsby builds for the host you will actually run on.
  3. Upgrade/downgrade lmdb (via overrides/resolutions) to a version that ships a binary for your target.
  4. For alpine/musl, ensure the musl-specific lmdb prebuild package is available or switch to a glibc-based image.

Example fix

# before
gatsby build --functions-platform=linux --functions-arch=armv7 # unsupported
# after
gatsby build --functions-platform=linux --functions-arch=arm64
Defensive patterns

Strategy: validation

Validate before calling

// Validate the target before invoking a cross-build.
const SUPPORTED = new Set(['linux-x64','linux-arm64','darwin-x64','darwin-arm64','win32-x64'])
function checkFunctionsTarget(platform, arch) {
  if (!SUPPORTED.has(`${platform}-${arch}`)) {
    throw new Error(`Unsupported functions target ${platform}/${arch}; pick from ${[...SUPPORTED].join(', ')}`)
  }
}

Type guard

function isSupportedLmdbTarget(platform, arch) {
  const lmdb = require('lmdb/package.json')
  return Object.keys(lmdb.optionalDependencies || {})
    .some(p => p.includes(`@lmdb/${platform}-${arch}`) || p.includes(`${platform}-${arch}`))
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13). Data as JSON: /api/errors/7cf90ed27ae7251a. Report an issue: GitHub.