apple/pkl · error
cannotGlobUri
cannotGlobUri
Error message
cannotGlobUri
What it means
Thrown when an import marked as a glob (isGlob = true) resolves to a URI whose scheme/module key does not support globbing. Glob resolution expands a wildcard pattern into multiple modules, which only scheme handlers whose module key `isGlobbable()` (e.g. file, project resources) can do; schemes like http(s), env, or custom external readers are rejected with the URI and its scheme in the message.
Source
Thrown at pkl-core/src/main/java/org/pkl/core/runtime/CommandSpecParser.java:1190
.build();
}
var isGlob = (Boolean) VmUtils.readMember(mport, Identifier.GLOB);
var importUri = URI.create(uriString);
var language = VmLanguage.get(null);
// non-glob
if (!isGlob) {
var moduleKey = moduleResolver.resolve(importUri);
return language.loadModule(moduleKey);
}
// glob
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();View on GitHub (pinned to f3efcbfc9b)
Solutions
- Remove `glob = true` and enumerate the imports explicitly
- Switch to a globbable scheme (e.g. local file paths) if wildcard expansion is needed
- Fetch the remote files locally (or use a project/resolver that supports globs) and glob over the local paths
Example fix
// before
new Import { uri = "https://example.com/*.pkl"; glob = true }
// after
new Import { uri = "file://./modules/*.pkl"; glob = true } Defensive patterns
Strategy: validation
Validate before calling
// only mark globs on schemes that support them
const GLOBBABLE_SCHEMES = ["file", "untitled"]
function canGlob(uri: String): Boolean =
uri.startsWith("/") || GLOBBABLE_SCHEMES.any((s) -> uri.startsWith(s + "://")) Type guard
function isGlobbableImport(uri: String, glob: Boolean): Boolean =
!glob || uri.startsWith("file://") || uri.startsWith("/") Prevention
- Only set glob = true on local file (or project resource) URIs
- Enumerate remote imports explicitly instead of globbing over http(s)/env schemes
- Test glob imports locally before pointing them at other schemes
When it happens
Trigger: Writing `uri = "https://example.com/*.pkl"; glob = true` (or `env://.../*.pkl`) in an import entry — after resolving the URI, globModuleKey.isGlobbable() returns false and handleImport throws.
Common situations: Adding `glob = true` to a remote HTTP import; assuming globs work over env/other schemes; moving a working local glob import to a hosted URL without removing glob.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/daf7d8929e393292.
Report an issue: GitHub.