{"record":{"id":"a94f99a11a68dbff","repo":"apple/pkl","slug":"cannotresolveinlocaldependencynotglobbable","errorCode":"cannotResolveInLocalDependencyNotGlobbable","errorMessage":"cannotResolveInLocalDependencyNotGlobbable","messagePattern":"cannotResolveInLocalDependencyNotGlobbable","errorType":"error_code","errorClass":"PackageLoadError","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/module/ModuleKeys.java","lineNumber":759,"sourceCode":"      }\n      var dep = (Dependency.RemoteDependency) dependency;\n      assert dep.getChecksums() != null;\n      var bytes = getPackageResolver().getBytes(packageAssetUri, false, dep.getChecksums());\n      return ResolvedModuleKeys.virtual(this, uri, new String(bytes, StandardCharsets.UTF_8), true);\n    }\n\n    @Override\n    public List<PathElement> listElements(SecurityManager securityManager, URI baseUri)\n        throws IOException, SecurityManagerException, ExternalReaderProcessException {\n      securityManager.checkResolveModule(baseUri);\n      var packageAssetUri = PackageAssetUri.create(baseUri);\n      var dependency =\n          getProjectDependenciesManager().getResolvedDependency(packageAssetUri.getPackageUri());\n      var local = getLocalUri(dependency, packageAssetUri);\n      if (local != null) {\n        var moduleKey = VmContext.get(null).getModuleResolver().resolve(local);\n        if (!moduleKey.isGlobbable()) {\n          throw new PackageLoadError(\n              \"cannotResolveInLocalDependencyNotGlobbable\", local.getScheme());\n        }\n        return moduleKey.listElements(securityManager, local);\n      }\n      var dep = (Dependency.RemoteDependency) dependency;\n      assert dep.getChecksums() != null;\n      return getPackageResolver().listElements(packageAssetUri, dep.getChecksums());\n    }\n\n    @Override\n    public boolean hasElement(SecurityManager securityManager, URI elementUri)\n        throws IOException, SecurityManagerException, ExternalReaderProcessException {\n      securityManager.checkResolveModule(elementUri);\n      var packageAssetUri = PackageAssetUri.create(elementUri);\n      var dependency =\n          getProjectDependenciesManager().getResolvedDependency(packageAssetUri.getPackageUri());\n      var local = getLocalUri(dependency, packageAssetUri);\n      if (local != null) {","sourceCodeStart":741,"sourceCodeEnd":777,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/module/ModuleKeys.java#L741-L777","documentation":"When a module is imported through a package that is mapped to a local dependency, Pkl resolves the import target on the local filesystem. After resolving, it checks that the resulting module key supports glob (wildcard) imports; if the URI scheme of the local path does not support globbing, this PackageLoadError is thrown during module listing.","triggerScenarios":"Calling the module-listing path for a package-asset URI where getProjectDependenciesManager().getResolvedDependency() returned a LocalDependency and the resolved local module key (from ModuleResolver.resolve(local)) has isGlobbable() == false, e.g. the local URI scheme cannot expand glob patterns.","commonSituations":"Using a local path dependency in PklProject.deps.json that points at a file whose scheme (e.g. a custom or non-file scheme) does not support glob imports, then importing modules from it with a glob pattern like `import \"pkg://.../**/*.pkl\"`.","solutions":["Use a plain `file://` (or platform path) URI for the local dependency so the resolved module key is globbable.","Remove the glob (`**`/`*`) pattern from the import and import concrete module paths instead.","Check the local dependency mapping: the local URI's scheme must support globbing; adjust getLocalUri output or the dependency definition.","If this is a custom ModuleKey implementation, implement isGlobbable() to return true and support listElements."],"exampleFix":"// before (PklProject deps pointing at custom-scheme local path)\ndependencies { mypkg { uri = \"custom:///libs/mypkg\" } }\n// after\ndependencies { mypkg { uri = \"file:///libs/mypkg\" } }","handlingStrategy":"validation","validationCode":"// before importing with globs from a local dependency, check the local URI scheme\nboolean globbable = switch (localUri.getScheme()) {\n    case \"file\", null -> true;  // filesystem-backed schemes support globbing\n    default -> false;\n};\nif (!globbable) throw new IllegalStateException(\"Scheme \" + localUri.getScheme() + \" cannot be globbed\");","typeGuard":"boolean isGlobbableLocal(java.net.URI uri) {\n  String s = uri.getScheme();\n  return s == null || \"file\".equals(s);\n}","tryCatchPattern":"try {\n  moduleKeys = key.listElements(securityManager, local);\n} catch (PackageLoadError e) {\n  if (e.getMessage().contains(\"not globbable\")) {\n    throw new IllegalArgumentException(\"Import uses a glob pattern but local dependency scheme is not globbable: \" + local, e);\n  }\n  throw e;\n}","preventionTips":["Keep local dependency URIs on plain filesystem paths (file:// or relative paths).","Avoid glob imports (**) against dependencies; import concrete module paths.","If you write a custom ModuleKey, implement isGlobbable() and listElements() for any scheme you intend to glob.","Test glob imports against each dependency type you support in CI."],"tags":["pkl","dependency-resolution","glob-import","local-dependency"],"backgroundTag":"unsupported-operation","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}