GoogleContainerTools/jib · error · IllegalArgumentException

Path does not start with forward slash (/): ${unixPath}

Error message

Path does not start with forward slash (/): ${unixPath}

What it means

AbsoluteUnixPath represents a Unix path that must be absolute (start with '/'). The get() factory method validates this and throws IllegalArgumentException when the given string is relative or empty of a leading slash, because Jib container paths (like appRoot and layer extraction targets) must be container-absolute.

Source

Thrown at jib-build-plan/src/main/java/com/google/cloud/tools/jib/api/buildplan/AbsoluteUnixPath.java:45

/**
 * Represents a Unix-style path in absolute form (containing all path components relative to the
 * file system root {@code /}).
 *
 * <p>This class is immutable and thread-safe.
 */
@Immutable
public class AbsoluteUnixPath {

  /**
   * Gets a new {@link AbsoluteUnixPath} from a Unix-style path string. The path must begin with a
   * forward slash ({@code /}).
   *
   * @param unixPath the Unix-style path string in absolute form
   * @return a new {@link AbsoluteUnixPath}
   */
  public static AbsoluteUnixPath get(String unixPath) {
    if (!unixPath.startsWith("/")) {
      throw new IllegalArgumentException("Path does not start with forward slash (/): " + unixPath);
    }

    return new AbsoluteUnixPath(UnixPathParser.parse(unixPath));
  }

  /**
   * Gets a new {@link AbsoluteUnixPath} from a {@link Path}. The {@code path} must be absolute
   * (indicated by a non-null {@link Path#getRoot}).
   *
   * @param path the absolute {@link Path} to convert to an {@link AbsoluteUnixPath}.
   * @return a new {@link AbsoluteUnixPath}
   */
  public static AbsoluteUnixPath fromPath(Path path) {
    if (path.getRoot() == null) {
      throw new IllegalArgumentException(
          "Cannot create AbsoluteUnixPath from non-absolute Path: " + path);
    }

View on GitHub (pinned to fb949e2676)

Solutions

  1. Prefix the path with a forward slash before passing it to AbsoluteUnixPath.get()
  2. Validate user/config-supplied paths with path.startsWith("/") beforehand
  3. If the path comes from a Path object, use AbsoluteUnixPath.fromPath() with an absolute Path instead

Example fix

// before
AbsoluteUnixPath appRoot = AbsoluteUnixPath.get("app");
// after
AbsoluteUnixPath appRoot = AbsoluteUnixPath.get("/app");
Defensive patterns

Strategy: validation

Validate before calling

if (path == null || !path.startsWith("/")) throw new IllegalArgumentException("appRoot must be absolute: " + path);

Type guard

boolean isAbsoluteUnixPath(String p) { return p != null && p.startsWith("/"); }

Try / catch

try { AbsoluteUnixPath p = AbsoluteUnixPath.get(path); } catch (IllegalArgumentException e) { /* treat path as relative: p = AbsoluteUnixPath.get("/" + path); */ }

Prevention

When it happens

Trigger: Calling AbsoluteUnixPath.get() with a string that does not start with '/', e.g. get("app/libs") or get("").

Common situations: Config values like --app-root, target paths, or layer destination paths read from YAML/properties/user input that omit the leading slash (e.g. 'app' instead of '/app').

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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