apple/pkl · error · VmException

noResourceReaderRegistered

noResourceReaderRegistered

Error message

noResourceReaderRegistered

What it means

ResourceManager.getReader() looks up a ResourceReader by the resource URI's scheme. If none is registered for that scheme it throws eval error 'noResourceReaderRegistered' naming the scheme, meaning Pkl cannot read resources of that kind.

Source

Thrown at pkl-core/src/main/java/org/pkl/core/runtime/ResourceManager.java:64

  public ResourceManager(SecurityManager securityManager, Collection<ResourceReader> readers) {
    this.securityManager = securityManager;

    for (var reader : readers) {
      resourceReaders.put(reader.getUriScheme(), reader);
    }

    resourceFactory =
        new VmObjectFactory<Resource>(BaseModule::getResourceClass)
            .addProperty("uri", resource -> resource.uri().toString())
            .addProperty("text", Resource::getText)
            .addProperty("bytes", resource -> new VmBytes(resource.bytes()));
  }

  @TruffleBoundary
  public ResourceReader getReader(URI resourceUri, Node readNode) {
    var reader = resourceReaders.get(resourceUri.getScheme());
    if (reader == null) {
      throw new VmExceptionBuilder()
          .withLocation(readNode)
          .evalError("noResourceReaderRegistered", resourceUri.getScheme())
          .build();
    }
    return reader;
  }

  public Optional<Object> doRead(ResourceReader reader, URI uri, @Nullable Node readNode) {
    Optional<Object> resource;
    try {
      resource = reader.read(uri);
    } catch (IOException e) {
      throw new VmExceptionBuilder()
          .evalError("ioErrorReadingResource", uri)
          .withCause(e)
          .withOptionalLocation(readNode)
          .build();
    } catch (URISyntaxException e) {

View on GitHub (pinned to f3efcbfc9b)

Solutions

  1. Fix the scheme typo in the read() call (e.g. 'prop:', 'env:', 'file:', 'https:').
  2. In embedded usage, register a ResourceReader for the scheme when building the evaluator.
  3. Check that the Pkl version/CLI config enables the reader you expect (e.g. http reads may be restricted).

Example fix

// before
read("environment:PATH")
// after
read("env:PATH")
Defensive patterns

Strategy: validation

Validate before calling

String scheme = resourceUri.getScheme();
if (scheme == null || !registeredSchemes.contains(scheme)) { /* avoid read or register a reader */ }

Try / catch

catch (VmException e) { if ("noResourceReaderRegistered".equals(e.getCode())) { /* handle unsupported scheme */ } }

Prevention

When it happens

Trigger: Calling getReader(URI, Node) (via resource read paths in Pkl code, e.g. `read("env:FOO")` or custom scheme) where resourceReaders.get(scheme) returns null.

Common situations: Using a custom scheme like 'env:foo' when the env resource reader is not registered; typos in scheme; embedded usage where the application only registered a subset of readers (e.g. no http reader).

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08). Data as JSON: /api/errors/95553359982523da. Report an issue: GitHub.