Skip to content
Latchkey

Gradle "Could not create service of type ..." - Fix Daemon Startup in CI

Gradle failed while wiring up its internal services at startup. Could not create service of type ... means the daemon could not initialize - usually a corrupt or unwritable ~/.gradle (the Gradle user home), or a JDK the Gradle version cannot run on.

What this error means

The build fails before any task with Gradle could not start your build. and Could not create service of type <X> using <Services>. It happens during bootstrap, not in your build logic.

gradle output
FAILURE: Build failed with an exception.
* What went wrong:
Gradle could not start your build.
> Could not create service of type FileHasher using
  GradleUserHomeScopeServices.createCachingFileHasher().
   > Could not open ... cache (corrupt).

Common causes

Corrupt or unwritable Gradle user home

A corrupt ~/.gradle/caches, or a Gradle user home the job user cannot write (wrong ownership in a container, HOME unset), stops service initialization.

Incompatible JDK running Gradle

Running Gradle on a JDK outside its supported range can break service creation during bootstrap, before your build is configured.

How to fix it

Reset the Gradle user home

Clear caches and ensure the Gradle user home is writable by the job user.

Terminal
rm -rf ~/.gradle/caches
export GRADLE_USER_HOME="$PWD/.gradle"
mkdir -p "$GRADLE_USER_HOME"
./gradlew --no-daemon help

Run Gradle on a supported JDK

Provision a JDK within the Gradle version’s supported range for the Gradle-runtime process.

.github/workflows/ci.yml
- uses: actions/setup-java@v4
  with:
    distribution: temurin
    java-version: '17'
- run: ./gradlew --version

How to prevent it

  • Set GRADLE_USER_HOME to a writable, cacheable path in CI.
  • Ensure HOME and ownership are correct for the job user in containers.
  • Keep the Gradle wrapper aligned with a supported JDK.

Frequently asked questions

What causes ""Could not create service of type""?
A corrupt ~/.gradle/caches, or a Gradle user home the job user cannot write (wrong ownership in a container, HOME unset), stops service initialization.
How do I fix "Could not create service of type"?
Clear caches and ensure the Gradle user home is writable by the job user.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card