elastic/elasticsearch · critical · GradleException

Cannot load VersionPropertiesBuildService

Error message

Cannot load VersionPropertiesBuildService

What it means

VersionPropertiesBuildService is a Gradle BuildService that loads the Elasticsearch version and minimum Java toolchain requirements once per build. This GradleException is the catch-all wrapper around any IOException thrown while reading version.properties or resolving the minimumRuntime/minimumCompiler Java version files. When it fires the build cannot determine its own version, which blocks nearly every downstream task that depends on VersionProperties.

Source

Thrown at build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/VersionPropertiesBuildService.java:38

import java.io.File;
import java.io.IOException;
import java.util.Properties;
import javax.inject.Inject;

public abstract class VersionPropertiesBuildService implements BuildService<VersionPropertiesBuildService.Params>, AutoCloseable {

    private final Properties properties;

    @Inject
    public VersionPropertiesBuildService(ProviderFactory providerFactory) {
        File infoPath = getParameters().getInfoPath().getAsFile().get();
        try {
            File propertiesInputFile = new File(infoPath, "version.properties");
            properties = VersionPropertiesLoader.loadBuildSrcVersion(propertiesInputFile, providerFactory);
            properties.computeIfAbsent("minimumRuntimeJava", s -> resolveMinimumRuntimeJavaVersion(infoPath));
            properties.computeIfAbsent("minimumCompilerJava", s -> resolveMinimumCompilerJavaVersion(infoPath));
        } catch (IOException e) {
            throw new GradleException("Cannot load VersionPropertiesBuildService", e);
        }
    }

    private JavaVersion resolveMinimumRuntimeJavaVersion(File infoPath) {
        return resolveJavaVersion(infoPath, "src/main/resources/minimumRuntimeVersion");
    }

    private JavaVersion resolveMinimumCompilerJavaVersion(File infoPath) {
        return resolveJavaVersion(infoPath, "src/main/resources/minimumCompilerVersion");
    }

    private JavaVersion resolveJavaVersion(File infoPath, String path) {
        final JavaVersion minimumJavaVersion;
        File minimumJavaInfoSource = new File(infoPath, path);
        try {
            String versionString = FileUtils.readFileToString(minimumJavaInfoSource);
            minimumJavaVersion = JavaVersion.toVersion(versionString);
        } catch (IOException e) {

View on GitHub (pinned to db6a809a66)

Solutions

  1. Inspect the caused-by IOException in the stack trace to find the exact file path that failed to read.
  2. Verify infoPath contains version.properties and build-conventions/src/main/resources/minimumRuntimeVersion and minimumCompilerVersion.
  3. Re-run a full clone or `git checkout -- .` to restore missing files; avoid shallow/sparse clones for the build.
  4. Run from the repo root via the bundled ./gradlew wrapper so the infoPath parameter resolves correctly.

Example fix

// before: running from a submodule dir loses the infoPath root
gradle -p build-conventions help
// after: run from the repo root so infoPath == repo root
./gradlew help
Defensive patterns

Strategy: validation

Validate before calling

// Run before the build service is constructed (e.g. in settings.gradle or a config check task)
File infoPath = new File(rootProject.projectDir, "build-conventions");
File[] required = {
    new File(infoPath, "version.properties"),
    new File(infoPath, "src/main/resources/minimumRuntimeVersion"),
    new File(infoPath, "src/main/resources/minimumCompilerVersion")
};
for (File f : required) {
    if (!f.isFile()) {
        throw new GradleException("Missing VersionPropertiesBuildService input: " + f);
    }
}

Prevention

When it happens

Trigger: Constructing the build service when getParameters().getInfoPath() points to a directory whose version.properties is missing or unreadable, or when the computeIfAbsent calls for minimumRuntimeJava / minimumCompilerJava hit a missing src/main/resources/minimumRuntimeVersion or minimumCompilerVersion file. Any IOException inside the try block in the constructor is rethrown as this message.

Common situations: Running Gradle from the wrong working directory so infoPath resolves outside the repo; a shallow/sparse checkout missing build-conventions resources; a corrupted or half-applied stash that deleted version.properties; file locked by AV/indexer on Windows; a moved checkout whose relative infoPath no longer matches.

Related errors


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