apple/pkl · error · InvalidUserDataException

No project directories specified.

Error message

No project directories specified.

What it means

ProjectResolveTask resolves dependencies of Pkl projects; doRunTask converts projectDirectories to Paths and throws InvalidUserDataException if none were specified. Resolution requires at least one project directory whose dependencies can be computed and downloaded.

Source

Thrown at pkl-gradle/src/main/java/org/pkl/gradle/task/ProjectResolveTask.java:59

  @PathSensitive(PathSensitivity.ABSOLUTE)
  public Provider<List<File>> getProjectPklFiles() {
    return getProjectDirectories()
        .getElements()
        .map(
            (files) ->
                files.stream()
                    .map((it) -> it.getAsFile().toPath().resolve("PklProject").toFile())
                    .collect(Collectors.toList()));
  }

  @Override
  protected void doRunTask() {
    var projectDirectories =
        getProjectDirectories().getFiles().stream()
            .map(it -> Path.of(it.getAbsolutePath()))
            .collect(Collectors.toList());
    if (projectDirectories.isEmpty()) {
      throw new InvalidUserDataException("No project directories specified.");
    }
    new CliProjectResolver(
            getCliBaseOptions(),
            projectDirectories,
            new PrintWriter(System.out),
            new PrintWriter(System.err))
        .run();
  }
}

View on GitHub (pinned to f3efcbfc9b)

Solutions

  1. Configure `projectDirectories = files("<dir-with-PklProject>")` on the task or extension.
  2. Confirm the directories contain a PklProject file and resolve non-empty.
  3. Ensure configuration lives in the same subproject as the task execution.
  4. Skip the task (onlyIf) for projects that need no dependency resolution.

Example fix

// before
val pklResolve by tasks.existing(PklProjectResolveTask::class)
// after
tasks.withType<PklProjectResolveTask>().configureEach { projectDirectories = files(rootDir) }
Defensive patterns

Strategy: validation

Validate before calling

val dirs = task.projectDirectories.files
require(dirs.isNotEmpty()) { "pklResolve requires projectDirectories" }

Type guard

fun PklProjectResolveTask.hasDirectories() = projectDirectories.files.isNotEmpty()

Try / catch

try { resolveTask.doRunTask() } catch (InvalidUserDataException e) { if (e.message == "No project directories specified.") logger.error("Configure projectDirectories for pklProjectResolve"); throw e }

Prevention

When it happens

Trigger: Running the pklProjectResolve task without configuring projectDirectories (empty files set) on the task or via the pkl extension.

Common situations: New project where the resolve task was run before wiring configuration; copy-pasted task setup that dropped the projectDirectories line; CI invoking the task in a subproject lacking configuration.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08). Data as JSON: /api/errors/232435f3f86b23d7. Report an issue: GitHub.