GoogleContainerTools/jib · error · InvalidAppRootException

${appRoot}

Error message

${appRoot}

What it means

Jib resolves the appRoot configuration (where the app is placed in the container, e.g. /app) via getAppRootChecked. If appRoot is set but is not a valid absolute Unix path, AbsoluteUnixPath.get fails and Jib throws InvalidAppRootException wrapping the configured value. An empty appRoot falls back to defaults (/app or the Jetty webapps root for WARs), so the error only occurs for non-empty invalid values.

Source

Thrown at jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java:869

   * @param projectProperties the project properties
   * @return the app root value
   * @throws InvalidAppRootException if {@code appRoot} value is not an absolute Unix path
   */
  @VisibleForTesting
  static AbsoluteUnixPath getAppRootChecked(
      RawConfiguration rawConfiguration, ProjectProperties projectProperties)
      throws InvalidAppRootException {
    String appRoot = rawConfiguration.getAppRoot();
    if (appRoot.isEmpty()) {
      appRoot =
          projectProperties.isWarProject()
              ? DEFAULT_JETTY_APP_ROOT
              : JavaContainerBuilder.DEFAULT_APP_ROOT;
    }
    try {
      return AbsoluteUnixPath.get(appRoot);
    } catch (IllegalArgumentException ex) {
      throw new InvalidAppRootException(appRoot, appRoot, ex);
    }
  }

  static ContainerizingMode getContainerizingModeChecked(
      RawConfiguration rawConfiguration, ProjectProperties projectProperties)
      throws InvalidContainerizingModeException {
    ContainerizingMode mode = ContainerizingMode.from(rawConfiguration.getContainerizingMode());
    if (mode == ContainerizingMode.PACKAGED && projectProperties.isWarProject()) {
      throw new UnsupportedOperationException(
          "packaged containerizing mode for WAR is not yet supported");
    }
    return mode;
  }

  @VisibleForTesting
  static Optional<AbsoluteUnixPath> getWorkingDirectoryChecked(RawConfiguration rawConfiguration)
      throws InvalidWorkingDirectoryException {
    Optional<String> directory = rawConfiguration.getWorkingDirectory();

View on GitHub (pinned to fb949e2676)

Solutions

  1. Prefix the appRoot with '/', e.g. /app instead of app.
  2. Remove invalid characters, quotes, or surrounding whitespace from the appRoot value.
  3. If you actually want the default, clear the value entirely so Jib falls back to /app (or the Jetty default for WAR projects).

Example fix

// before
jib {
  container { appRoot = 'myapp' }
}
// after
jib {
  container { appRoot = '/myapp' }
}
Defensive patterns

Strategy: validation

Validate before calling

// Validate appRoot before configuring Jib
if (appRoot != null && !appRoot.isEmpty() && !appRoot.startsWith("/")) {
  throw new IllegalArgumentException("appRoot must be an absolute unix path: " + appRoot);
}

Try / catch

try {
  processCommonConfiguration(...);
} catch (InvalidAppRootException e) {
  logger.error("Invalid appRoot '" + e.getInvalidAppRoot() + "'; must start with / (default: /app)");
}

Prevention

When it happens

Trigger: processCommonConfiguration -> getAppRootChecked when rawConfiguration.getAppRoot() is non-empty and AbsoluteUnixPath.get(appRoot) throws IllegalArgumentException (relative path, trailing/invalid characters, Windows path).

Common situations: Setting jib.container.appRoot = 'app' (missing leading slash); setting appRoot to a Windows-style path; stray quotes or spaces in the configured value; using a trailing slash segment pattern AbsoluteUnixPath rejects.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06). Data as JSON: /api/errors/59a92c6e023184fa. Report an issue: GitHub.