apple/pkl · error · VmException

ioErrorResolvingGlob

ioErrorResolvingGlob

Error message

I/O error resolving glob pattern `{0}`.

What it means

Pkl throws this when resolving a glob import (enumerating the files matching the pattern) fails with an IOException that is not attributable to another specific handler — e.g. I/O trouble while listing directory entries or fetching remote elements. The import URI is reported and the IOException is attached as cause.

Source

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

        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();
    } catch (SecurityManagerException | HttpClientException e) {
      throw exceptionBuilder().withCause(e).build();
    } catch (PackageLoadError e) {
      throw exceptionBuilder().adhocEvalError(e.getMessage()).build();
    } catch (InvalidGlobPatternException e) {
      throw exceptionBuilder()
          .evalError("invalidGlobPattern", globPattern)
          .withHint(e.getMessage())
          .build();
    } catch (ExternalReaderProcessException e) {
      throw exceptionBuilder().evalError("externalReaderFailure").withCause(e).build();
    }
  }
}

View on GitHub (pinned to f3efcbfc9b)

Solutions

  1. Check permissions on the directory being globbed (needs read/execute).
  2. Verify network/storage availability if the glob path is remote or on a mount.
  3. Inspect the cause chain for the exact IOException and address that failure.
  4. Retry the evaluation if the failure was transient.

Example fix

// before
import "/root-protected/*.pkl" as mods*  // permission denied
// after
chmod +rx /root-protected  // or glob a readable directory
import "./configs/*.pkl" as mods*
Defensive patterns

Strategy: retry

Validate before calling

// Host-side pre-check: directory exists and is readable
//   Files.isDirectory(dir) && Files.isReadable(dir)

Try / catch

// Retry transient failures around evaluation:
for (attempt in 1..3) {
  try { return eval(); }
  catch (PklException e) {
    if (e.message?.contains("I/O error resolving glob") == true && attempt < 3) { backoff(); continue; }
    throw e;
  }
}

Prevention

When it happens

Trigger: Evaluating a glob import where directory enumeration fails: unreadable directory, network failure during a remote glob resolution, or an interrupted filesystem operation.

Common situations: Globbing a directory without read/execute permissions; glob over a network-mounted path that dropped; transient network error while globbing package contents.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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