gatsbyjs/gatsby · error · Error
Target platform/arch for functions execution
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.
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.
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
- 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.
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
- Failed to find required LMDB binary
- Failed to locate or install LMDB binary for functions…
- Failed to locate or install Sharp binary for functions…
- Incompatible DSG/SSR executing environment. Function was…
- Bad filter value for predicate
AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13).
Data as JSON: /api/errors/7cf90ed27ae7251a.
Report an issue: GitHub.
Appendix: 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)