apple/pkl · error
ioErrorResolvingGlob
ioErrorResolvingGlob
Error message
ioErrorResolvingGlob
What it means
When evaluating a Pkl glob import (e.g. import("glob:*.pkl")), CommandSpecParser.handleImport resolves matching modules. If an I/O error (file system failure, unreadable directory, closed stream) occurs while listing or reading files matched by the glob pattern, the evaluator wraps the IOException in this `ioErrorResolvingGlob` eval error, carrying the import URI and the original IOException as cause.
Source
Thrown at pkl-core/src/main/java/org/pkl/core/runtime/CommandSpecParser.java:1204
var globModuleKey = moduleResolver.resolve(importUri);
try {
if (!globModuleKey.isGlobbable()) {
throw exceptionBuilder()
.evalError("cannotGlobUri", importUri, importUri.getScheme())
.build();
}
var resolvedElements =
GlobResolver.resolveGlob(securityManager, globModuleKey, null, null, uriString);
var builder = new VmObjectBuilder(resolvedElements.size());
for (var entry : resolvedElements.entrySet()) {
var moduleKey = moduleResolver.resolve(entry.getValue().uri());
builder.addEntry(entry.getKey(), language.loadModule(moduleKey));
}
return builder.toMapping(resolvedElements);
} catch (IOException e) {
throw exceptionBuilder().evalError("ioErrorResolvingGlob", importUri).withCause(e).build();
} catch (ExternalReaderProcessException e) {
throw exceptionBuilder().evalError("externalReaderFailure").withCause(e).build();
} catch (SecurityManagerException e) {
throw exceptionBuilder().withCause(e).build();
} catch (InvalidGlobPatternException e) {
throw exceptionBuilder()
.evalError("invalidGlobPattern", uriString)
.withHint(e.getMessage())
.build();
}
}
// endregion
// region utilities
private static @Nullable String exportNullableString(VmObjectLike value, Object key) {
var result = VmValue.export(VmUtils.readMember(value, key));
return result instanceof PNull ? null : (String) result;View on GitHub (pinned to f3efcbfc9b)
Solutions
- Check the `caused by` IOException in the Pkl stack trace to see the actual filesystem error and fix that (permissions, missing directory, mount).
- Verify every path in the glob import URI exists and is readable from the process running the Pkl evaluator.
- Narrow the glob pattern so it only matches accessible locations; avoid globbing across network/unreliable mounts.
- Re-run the evaluation after restoring the directory or fixing permissions.
Example fix
// before: importing files from a directory that may not exist
x = import("glob:etc/plugins/*.pkl")
// after: guard the directory with a List import or ensure it exists in the environment
x = if (List(import("file:///etc/plugins")).isEmpty) Map() else import("glob:etc/plugins/*.pkl") Defensive patterns
Strategy: try-catch
Validate before calling
// shell pre-check before running pkl test -d "$(dirname "$glob_base")" && ls "$glob_base" >/dev/null || echo "glob target missing/unreadable"
Try / catch
// CLI: inspect the 'caused by' IOException on failure and retry after fixing filesystem access
pkl eval config.pkl || { grep -A2 'ioErrorResolvingGlob' pkl.log; exit 1; } Prevention
- Ensure glob base directories exist and are readable by the evaluating process
- Avoid globbing across network or ephemeral mounts
- Pin down the working directory with absolute glob URIs
- Check mount/permission state in CI before evaluation
When it happens
Trigger: Resolving a glob import via GlobResolver.resolveGlob where the underlying I/O throws an IOException — e.g. the glob's base directory was deleted between resolution and read, a permissions problem on the filesystem, or an external-reader-backed glob returning a broken stream.
Common situations: Config evaluates `import("glob:configs/*.pkl")` while the directory was renamed/mounted differently; CI runners without read permission on the matched directory; globbing over network mounts that dropped mid-evaluation.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- ioErrorWritingTestOutputFile
- ioErrorReadingTestOutputFile
- ioErrorLoadingModule
- ioErrorLoadingModule
- Failed to write to $depsFile: ${e.message}
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/b2257071e0a62369.
Report an issue: GitHub.