apple/pkl · error · VmException

cannotGlobUri

cannotGlobUri

Error message

Cannot expand glob pattern `{0}` because scheme `{1}` is not globbable.

What it means

Pkl throws this when a glob import's URI targets a scheme that does not support glob expansion. Each module scheme declares whether it is globbable; the resolver refuses to expand globs over schemes that cannot enumerate children (e.g. https), reporting the import URI and its scheme.

Source

Thrown at pkl-core/src/main/java/org/pkl/core/ast/expression/unary/ImportGlobNode.java:80

              sourceSection,
              "",
              language,
              new FrameDescriptor(),
              new ImportGlobMemberBodyNode(sourceSection, language, currentModule));
    }
    return memberNode;
  }

  @Override
  public Object executeGeneric(VirtualFrame frame) {
    if (cachedResult != null) return cachedResult;

    CompilerDirectives.transferToInterpreterAndInvalidate();
    var context = VmContext.get(this);
    try {
      var moduleKey = context.getModuleResolver().resolve(importUri, this);
      if (!moduleKey.isGlobbable()) {
        throw exceptionBuilder()
            .evalError("cannotGlobUri", importUri, importUri.getScheme())
            .build();
      }
      var resolvedElements =
          GlobResolver.resolveGlob(
              context.getSecurityManager(),
              moduleKey,
              currentModule.getOriginal(),
              currentModule.getUri(),
              globPattern);
      var builder = new VmObjectBuilder(resolvedElements.size());
      for (var entry : resolvedElements.entrySet()) {
        builder.addEntry(entry.getKey(), getMemberNode());
      }
      cachedResult = builder.toMapping(resolvedElements);
      return cachedResult;
    } catch (IOException e) {
      throw exceptionBuilder().evalError("ioErrorResolvingGlob", importUri).withCause(e).build();

View on GitHub (pinned to f3efcbfc9b)

Solutions

  1. Change the glob import to a globbable scheme, e.g. file paths within the project.
  2. List the remote modules explicitly with separate import statements instead of a glob.
  3. If resources come from a package, check the package's supported globbing scheme.
  4. Use a local mirror/checkout of the remote files, then glob locally.

Example fix

// before
import "https://example.com/envs/*.pkl" as envs*
// after
import "./envs/*.pkl" as envs*
Defensive patterns

Strategy: validation

Validate before calling

// Only use glob syntax with file-based (or otherwise globbable) imports:
// globImport only if uri.startsWith("file:") or a known globbable package scheme

Prevention

When it happens

Trigger: Writing `import "https://example.com/conf/*.pkl" as conf*` or any glob import over a non-globbable scheme such as https/http; only local file and some package schemes support globs.

Common situations: Assuming remote URLs can be glob-imported like local files; migrating a file-based glob import to a hosted URL without realizing enumeration is impossible over HTTP.

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/765439ca1b6c1964. Report an issue: GitHub.