apple/pkl · error · PackageLoadError
cannotResolveInLocalDependencyNotGlobbableNorLocal
cannotResolveInLocalDependencyNotGlobbableNorLocal
Error message
cannotResolveInLocalDependencyNotGlobbableNorLocal
What it means
Similar to error 130 but on the has-element path: when checking whether an element exists inside a local package dependency, the resolved module key must either support globbing or be a local (filesystem-backed) key. If the resolved key is neither globbable nor local, Pkl throws this PackageLoadError because it cannot interrogate the element's existence through that scheme.
Source
Thrown at pkl-core/src/main/java/org/pkl/core/module/ModuleKeys.java:780
return moduleKey.listElements(securityManager, local);
}
var dep = (Dependency.RemoteDependency) dependency;
assert dep.getChecksums() != null;
return getPackageResolver().listElements(packageAssetUri, dep.getChecksums());
}
@Override
public boolean hasElement(SecurityManager securityManager, URI elementUri)
throws IOException, SecurityManagerException, ExternalReaderProcessException {
securityManager.checkResolveModule(elementUri);
var packageAssetUri = PackageAssetUri.create(elementUri);
var dependency =
getProjectDependenciesManager().getResolvedDependency(packageAssetUri.getPackageUri());
var local = getLocalUri(dependency, packageAssetUri);
if (local != null) {
var moduleKey = VmContext.get(null).getModuleResolver().resolve(local);
if (!moduleKey.isGlobbable() && !moduleKey.isLocal()) {
throw new PackageLoadError(
"cannotResolveInLocalDependencyNotGlobbableNorLocal", local.getScheme());
}
return moduleKey.hasElement(securityManager, local);
}
var dep = (Dependency.RemoteDependency) dependency;
assert dep.getChecksums() != null;
return getPackageResolver().hasElement(packageAssetUri, dep.getChecksums());
}
@Override
protected Map<String, ? extends Dependency> getDependencies()
throws IOException, SecurityManagerException {
var packageUri = packageAssetUri.getPackageUri();
var projectResolver = getProjectDependenciesManager();
if (projectResolver.isLocalPackage(packageUri)) {
return projectResolver.getLocalPackageDependencies(packageUri);
}
var dep =View on GitHub (pinned to f3efcbfc9b)
Solutions
- Point the local dependency at a filesystem (file:// or relative path) URI so the resolved key is local.
- If glob support is intended, use a scheme whose module key implements isGlobbable() = true.
- Fix the local-URI mapping (getLocalUri) so it never yields a remote/virtual scheme for local dependencies.
- In custom ModuleKey implementations, ensure isLocal() or isGlobbable() is true and hasElement() is supported.
Example fix
// before: local dep resolving to remote-scheme URI "local": "https://example.com/mypkg" // after: local dep resolving to a filesystem path "local": "file:///workspace/mypkg"
Defensive patterns
Strategy: validation
Validate before calling
// before checking element existence via a local dependency, verify the resolved key is usable
var resolved = moduleResolver.resolve(localUri);
boolean usable = resolved.isGlobbable() || resolved.isLocal();
if (!usable) throw new IllegalStateException("Scheme " + localUri.getScheme() + " is neither globbable nor local"); Type guard
boolean isLocalOrGlobbable(ModuleKey key) {
return key.isLocal() || key.isGlobbable();
} Try / catch
try {
has = key.hasElement(securityManager, local);
} catch (PackageLoadError e) {
if (e.getMessage().contains("not globbable and is not local")) {
throw new IllegalArgumentException("Cannot query elements through scheme " + local + "; use a filesystem-backed local dependency", e);
}
throw e;
} Prevention
- Use filesystem-backed URIs for local dependencies in PklProject.deps.json.
- Do not map local dependencies to remote/virtual schemes via custom resolvers.
- For custom ModuleKeys, ensure hasElement() is implemented and isLocal()/isGlobbable() returns true.
- Validate local dependency URIs at project configuration time, not at import time.
When it happens
Trigger: Calling the hasElement path for a package-asset URI backed by a LocalDependency where ModuleResolver.resolve(local) returns a key with isGlobbable() == false AND isLocal() == false, e.g. a remote or virtual scheme used as a local dependency target.
Common situations: A local dependency URI resolving to a non-filesystem scheme (custom module path entry, virtual scheme), so membership checks on package elements fail; typically a misconfigured local dependency or custom module path scheme.
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
- cannotResolveInLocalDependencyNotGlobbable
- projectDependenciesLocalDependencyOutOfSync
- No project directories specified.
- cannotGlobUri
- Node `%s` of type `%s` does not have a property named `%s`.
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/345074f5a6b38b5b.
Report an issue: GitHub.