GoogleContainerTools/jib · error · IllegalArgumentException
Cannot resolve against absolute Path: ${relativePath}
Error message
Cannot resolve against absolute Path: ${relativePath} What it means
AbsoluteUnixPath.resolve() appends a relative path to this absolute path. Because the argument must be relative, it throws IllegalArgumentException when the given Path has a root (is absolute), since resolving against an absolute path would discard the base — likely indicating a caller mistake.
Source
Thrown at jib-build-plan/src/main/java/com/google/cloud/tools/jib/api/buildplan/AbsoluteUnixPath.java:112
public AbsoluteUnixPath resolve(RelativeUnixPath relativeUnixPath) {
int newSize = pathComponents.size() + relativeUnixPath.getRelativePathComponents().size();
List<String> newPathComponents = new ArrayList<>(newSize);
newPathComponents.addAll(pathComponents);
newPathComponents.addAll(relativeUnixPath.getRelativePathComponents());
return new AbsoluteUnixPath(newPathComponents);
}
/**
* Resolves this path against another relative path (by the name elements of {@code
* relativePath}).
*
* @param relativePath the relative path to resolve against
* @return a new {@link AbsoluteUnixPath} representing the resolved path
*/
public AbsoluteUnixPath resolve(Path relativePath) {
if (relativePath.getRoot() != null) {
throw new IllegalArgumentException("Cannot resolve against absolute Path: " + relativePath);
}
return AbsoluteUnixPath.fromPath(Paths.get(unixPath).resolve(relativePath));
}
/**
* Resolves this path against another relative Unix path in string form.
*
* @param relativeUnixPath the relative path to resolve against
* @return a new {@link AbsoluteUnixPath} representing the resolved path
*/
public AbsoluteUnixPath resolve(String relativeUnixPath) {
return resolve(RelativeUnixPath.get(relativeUnixPath));
}
/**
* Returns the string form of the absolute Unix-style path.
*View on GitHub (pinned to fb949e2676)
Solutions
- Pass a relative Path (no leading slash / no root), e.g. Paths.get("app/libs")
- If the value is absolute, drop the resolve call and use AbsoluteUnixPath.get() or at() on the absolute path directly
- Strip the root component if a relative sub-path is truly needed
Example fix
// before
AbsoluteUnixPath p = appRoot.resolve(Paths.get("/app/libs"));
// after
AbsoluteUnixPath p = appRoot.resolve(Paths.get("libs")); Defensive patterns
Strategy: validation
Validate before calling
if (relativePath.getRoot() != null) throw new IllegalArgumentException("resolve() expects a relative path"); Type guard
boolean isRelativePath(Path p) { return p != null && p.getRoot() == null; } Try / catch
try { AbsoluteUnixPath p = base.resolve(rel); } catch (IllegalArgumentException e) { /* use the absolute path directly: AbsoluteUnixPath.fromPath(rel) */ } Prevention
- Only pass Paths built from relative strings to resolve()
- Check getRoot() != null as an assertion in calling code
- Use AbsoluteUnixPath.get()/at() when the path is already absolute
When it happens
Trigger: Calling absolutePath.resolve(Paths.get("/opt/app")) — i.e. passing a Path with a non-null root.
Common situations: Mixing up the order of arguments or reusing a container-absolute destination path where a relative sub-path was intended.
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
- Path does not start with forward slash (/): ${unixPath}
- Cannot create AbsoluteUnixPath from non-absolute Path: ${pat
- Path starts with forward slash (/): ${relativePath}
- platforms set cannot be empty
- container.appRoot is not an absolute Unix-style path: ${inva
AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06).
Data as JSON: /api/errors/79ea7b28d8966ea0.
Report an issue: GitHub.