apple/pkl · error · InvalidUserDataException
No project directories specified.
Error message
No project directories specified.
What it means
ProjectPackageTask packages Pkl projects; doRunTask maps the configured projectDirectories files to Paths and throws InvalidUserDataException when the list is empty. Packaging needs at least one project directory to produce an artifact, so an empty configuration is rejected up front.
Source
Thrown at pkl-gradle/src/main/java/org/pkl/gradle/task/ProjectPackageTask.java:85
@Optional
public abstract Property<Boolean> getInstall();
@Input
@Optional
public abstract Property<String> getTestReporter();
public ProjectPackageTask() {
this.getJunitAggregateSuiteName().convention("pkl-tests");
}
@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 CliProjectPackager(
getCliBaseOptions(),
projectDirectories,
new CliTestOptions(
mapAndGetOrNull(getJunitReportsDir(), it -> it.getAsFile().toPath()),
getOverwrite().get(),
getJunitAggregateReports().getOrElse(false),
getJunitAggregateSuiteName().get(),
toTestReporter(getTestReporter())),
getOutputPath().get().getAsFile().getAbsolutePath(),
getSkipPublishCheck().getOrElse(false),
getInstall().getOrElse(false),
new PrintWriter(System.out),
new PrintWriter(System.err))
.run();
}View on GitHub (pinned to f3efcbfc9b)
Solutions
- Set projectDirectories on the task/extension, e.g. `projectDirectories = files(".")` or the directories containing PklProject files.
- Verify the configured paths actually resolve to existing files (an empty FileCollection triggers the same error).
- Check the task is being configured in the project where it runs.
- Disable/skip the task if packaging is not needed for that module.
Example fix
// before
val pklPackage by tasks.existing(PklProjectPackageTask::class)
// after
tasks.withType<PklProjectPackageTask>().configureEach { projectDirectories = files(".") } Defensive patterns
Strategy: validation
Validate before calling
val dirs = task.projectDirectories.files
require(dirs.isNotEmpty()) { "pklPackage requires projectDirectories; got ${dirs.size}" }
dirs.forEach { require(it.resolve("PklProject").exists()) { "No PklProject in ${it}" } } Type guard
fun PklProjectPackageTask.hasDirectories() = projectDirectories.files.isNotEmpty()
Try / catch
try { pkgTask.doRunTask() } catch (InvalidUserDataException e) { if (e.message == "No project directories specified.") logger.error("Set projectDirectories = files(...)"); throw e } Prevention
- Always configure projectDirectories = files(".") or explicit dirs
- Verify configured FileCollections resolve to existing dirs
- Centralize packaging config in a convention plugin
- Run packaging tasks only in modules that contain PklProject files
When it happens
Trigger: Running the pklPackage task with `projectDirectories` not set (or set to an empty set/files collection) in the task or pkl extension configuration.
Common situations: Forgot to add projectDirectories in build.gradle.kts; passed a FileCollection that resolves to nothing (bad pattern/excluded files); running the packaging task in a subproject with no Pkl projects.
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.
- Failed to parse Pkl module file path: ${notation}
- Failed to parse Pkl module URI: ${notation}
- Failed to parse Pkl module URI: ${s}
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/2ce5ac0b120ede92.
Report an issue: GitHub.