apple/pkl · error · VmException

rethrown VmException message (dynamic)

Error message

rethrown VmException message (dynamic)

What it means

If module resolution itself throws a VmException, the builder re-raises it as an eval error preserving the VmException's message, message arguments, hint, and cause. The dynamic message text therefore depends on the underlying resolution failure.

Solutions

  1. Read the rendered message and its cause chain to find the original failure
  2. Fix the specific resolution problem the message describes (path, syntax, or dependency)
  3. Re-run with verbose/stack-trace output to locate the originating module
Defensive patterns

Strategy: try-catch

Try / catch

// Catch the PklError, then walk getCause() chain to the original VmException and log its message + hints

Prevention

When it happens

Trigger: Any module-load step inside `resolveImport` (e.g. a nested import cycle detected, an evaluation error inside the imported module's loader) that surfaces as a VmException.

Common situations: Import chains failing deep inside a dependency; chained module errors where the root cause is an earlier throw wrapped as VmException.

Related errors


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

Appendix: source

Thrown at pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java:3265

            "To resolve modules in nested directories, use `/` as the directory separator.");
      }
      throw exceptionBuilder.build();
    } catch (URISyntaxException e) {
      throw exceptionBuilder()
          .evalError("invalidModuleUri", importUri)
          .withHint(e.getReason())
          .withSourceSection(createSourceSection(ctx))
          .build();
    } catch (IOException e) {
      throw exceptionBuilder()
          .evalError("ioErrorLoadingModule", importUri)
          .withCause(e)
          .withSourceSection(createSourceSection(ctx))
          .build();
    } catch (SecurityManagerException | PackageLoadError e) {
      throw exceptionBuilder().withSourceSection(createSourceSection(ctx)).withCause(e).build();
    } catch (VmException e) {
      throw exceptionBuilder()
          .evalError(e.getMessage(), e.getMessageArguments())
          .withCause(e.getCause())
          .withHintBuilder(e.getHintBuilder())
          .withSourceSection(createSourceSection(ctx))
          .build();
    } catch (ExternalReaderProcessException e) {
      throw exceptionBuilder()
          .evalError("externalReaderFailure")
          .withCause(e.getCause())
          .withSourceSection(createSourceSection(ctx))
          .build();
    }

    if (!resolvedUri.isAbsolute()) {
      throw exceptionBuilder()
          .evalError("cannotHaveRelativeImport", moduleKey.getUri())
          .withSourceSection(createSourceSection(ctx))
          .build();

View on GitHub (pinned to f3efcbfc9b)