elastic/elasticsearch · error · IllegalArgumentException

platform cannot be set on elasticsearch distribution [${name

Error message

platform cannot be set on elasticsearch distribution [${name}] of type [${type}]

What it means

Thrown by ElasticsearchDistribution.finalizeValues() when a distribution whose type is rpm, deb, or docker has its `platform` property explicitly set. These packaging formats are inherently platform-bound (deb/rpm are Linux-only, docker is multi-arch via image tags), so an explicit platform is meaningless and would mislead the resolver. The check guards the configuration-time invariant before the distribution is frozen.

Source

Thrown at build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java:257

                );
            }
            return;
        }

        if (isDocker() == false && failIfUnavailable.get() == false) {
            throw new IllegalArgumentException(
                "failIfUnavailable cannot be 'false' on elasticsearch distribution [" + name + "] of type [" + getType() + "]"
            );
        }

        if (getType() == ElasticsearchDistributionTypes.ARCHIVE) {
            // defaults for archive, set here instead of via convention so integ-test-zip can verify they are not set
            if (platform.isPresent() == false) {
                platform.set(CURRENT_PLATFORM);
            }
        } else { // rpm, deb or docker
            if (platform.isPresent()) {
                throw new IllegalArgumentException(
                    "platform cannot be set on elasticsearch distribution [" + name + "] of type [" + getType() + "]"
                );
            }
            if (isDocker()) {
                if (bundledJdk.isPresent()) {
                    throw new IllegalArgumentException(
                        "bundledJdk cannot be set on elasticsearch distribution [" + name + "] of type " + "[docker]"
                    );
                }
            }
        }

        if (bundledJdk.isPresent() == false) {
            bundledJdk.set(true);
        }

        version.finalizeValue();
        platform.finalizeValue();

View on GitHub (pinned to db6a809a66)

Solutions

  1. Remove the setPlatform(...) / platform = ... call from the rpm/deb/docker distribution configuration.
  2. If you need a specific OS image for docker, select it via the version/tag or a different distribution type rather than platform.
  3. Keep platform configuration only on ARCHIVE-type distributions, where it is meaningful and defaults to CURRENT_PLATFORM.

Example fix

// before
distributions {
  docker {
    platform = ElasticsearchDistribution.Platform.LINUX // throws at finalizeValues
  }
}
// after
distributions {
  docker {
    // platform omitted; docker image arch is selected via version/tag
  }
}
Defensive patterns

Strategy: validation

Validate before calling

// Before finalizing, check the type/platform compatibility
ElasticsearchDistribution dist = ...;
if (dist.getType() != ElasticsearchDistributionTypes.ARCHIVE) {
    assert dist.getPlatform() == null : "platform must not be set on non-ARCHIVE distribution " + dist.getName();
}

Prevention

When it happens

Trigger: Calling setPlatform(Platform.X) on an ElasticsearchDistribution whose getType() returns RPM, DEB, or DOCKER, then letting Gradle finalize the distribution's values (finalizeValues() runs during task graph configuration). Note ARCHIVE-type distributions are the only ones that accept (and auto-default) platform.

Common situations: Copy-pasting archive-style config (`dist.platform = ...`) into a docker/rpm/deb distribution block; migrating an archive distribution to docker without dropping the platform line; assuming platform is required for all distribution types because the ARCHIVE path auto-sets it.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/d4eb5de8b29b302c. Report an issue: GitHub.