{"record":{"id":"b2257071e0a62369","repo":"apple/pkl","slug":"ioerrorresolvingglob-b22570","errorCode":"ioErrorResolvingGlob","errorMessage":"ioErrorResolvingGlob","messagePattern":"ioErrorResolvingGlob","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/runtime/CommandSpecParser.java","lineNumber":1204,"sourceCode":"    var globModuleKey = moduleResolver.resolve(importUri);\n\n    try {\n      if (!globModuleKey.isGlobbable()) {\n        throw exceptionBuilder()\n            .evalError(\"cannotGlobUri\", importUri, importUri.getScheme())\n            .build();\n      }\n      var resolvedElements =\n          GlobResolver.resolveGlob(securityManager, globModuleKey, null, null, uriString);\n\n      var builder = new VmObjectBuilder(resolvedElements.size());\n      for (var entry : resolvedElements.entrySet()) {\n        var moduleKey = moduleResolver.resolve(entry.getValue().uri());\n        builder.addEntry(entry.getKey(), language.loadModule(moduleKey));\n      }\n      return builder.toMapping(resolvedElements);\n    } catch (IOException e) {\n      throw exceptionBuilder().evalError(\"ioErrorResolvingGlob\", importUri).withCause(e).build();\n    } catch (ExternalReaderProcessException e) {\n      throw exceptionBuilder().evalError(\"externalReaderFailure\").withCause(e).build();\n    } catch (SecurityManagerException e) {\n      throw exceptionBuilder().withCause(e).build();\n    } catch (InvalidGlobPatternException e) {\n      throw exceptionBuilder()\n          .evalError(\"invalidGlobPattern\", uriString)\n          .withHint(e.getMessage())\n          .build();\n    }\n  }\n\n  // endregion\n  // region utilities\n\n  private static @Nullable String exportNullableString(VmObjectLike value, Object key) {\n    var result = VmValue.export(VmUtils.readMember(value, key));\n    return result instanceof PNull ? null : (String) result;","sourceCodeStart":1186,"sourceCodeEnd":1222,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/runtime/CommandSpecParser.java#L1186-L1222","documentation":"When evaluating a Pkl glob import (e.g. import(\"glob:*.pkl\")), CommandSpecParser.handleImport resolves matching modules. If an I/O error (file system failure, unreadable directory, closed stream) occurs while listing or reading files matched by the glob pattern, the evaluator wraps the IOException in this `ioErrorResolvingGlob` eval error, carrying the import URI and the original IOException as cause.","triggerScenarios":"Resolving a glob import via GlobResolver.resolveGlob where the underlying I/O throws an IOException — e.g. the glob's base directory was deleted between resolution and read, a permissions problem on the filesystem, or an external-reader-backed glob returning a broken stream.","commonSituations":"Config evaluates `import(\"glob:configs/*.pkl\")` while the directory was renamed/mounted differently; CI runners without read permission on the matched directory; globbing over network mounts that dropped mid-evaluation.","solutions":["Check the `caused by` IOException in the Pkl stack trace to see the actual filesystem error and fix that (permissions, missing directory, mount).","Verify every path in the glob import URI exists and is readable from the process running the Pkl evaluator.","Narrow the glob pattern so it only matches accessible locations; avoid globbing across network/unreliable mounts.","Re-run the evaluation after restoring the directory or fixing permissions."],"exampleFix":"// before: importing files from a directory that may not exist\nx = import(\"glob:etc/plugins/*.pkl\")\n\n// after: guard the directory with a List import or ensure it exists in the environment\nx = if (List(import(\"file:///etc/plugins\")).isEmpty) Map() else import(\"glob:etc/plugins/*.pkl\")","handlingStrategy":"try-catch","validationCode":"// shell pre-check before running pkl\ntest -d \"$(dirname \"$glob_base\")\" && ls \"$glob_base\" >/dev/null || echo \"glob target missing/unreadable\"","typeGuard":null,"tryCatchPattern":"// CLI: inspect the 'caused by' IOException on failure and retry after fixing filesystem access\npkl eval config.pkl || { grep -A2 'ioErrorResolvingGlob' pkl.log; exit 1; }","preventionTips":["Ensure glob base directories exist and are readable by the evaluating process","Avoid globbing across network or ephemeral mounts","Pin down the working directory with absolute glob URIs","Check mount/permission state in CI before evaluation"],"tags":["pkl","io","glob-import","filesystem"],"backgroundTag":"file-read-failed","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}