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
- Configure `projectDirectories = files("<dir-with-PklProject>")` on the task or extension.
- Confirm the directories contain a PklProject file and resolve non-empty.
- Ensure configuration lives in the same subproject as the task execution.
- 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
- Configure projectDirectories in the same build script that applies the plugin
- Check that configured paths exist and contain PklProject files
- Use onlyIf { projectDirectories.files.isNotEmpty() } to skip gracefully
- Document required pkl task inputs in your build convention plugin
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
- No source modules specified.
- No project directories specified.
- cannotResolveInLocalDependencyNotGlobbable
- cannotResolveInLocalDependencyNotGlobbableNorLocal
- Failed to parse Pkl module file path: ${notation}
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/232435f3f86b23d7.
Report an issue: GitHub.