apple/pkl · error · CliException
Failed to download some packages. Failed to download $uri…
Error message
Failed to download some packages.
Failed to download $uri because:
${error.message} What it means
When two or more packages fail to download, the CLI aggregates all failures into one CliException listing "Failed to download some packages." followed by each URI and its error message. It lets you see every failure in one run instead of fixing them one at a time.
Solutions
- Read the per-URI causes in the message and fix each (URI, version, checksums, network).
- Retry after restoring network/registry access.
- Split the batch to isolate a failing package if the aggregate message is unclear.
- Use `--no-transitive` if a transitive dependency's resolution is failing.
Example fix
# before pkl package download package://old.example.com/a@1.0.0 package://old.example.com/b@1.0.0 # after (URIs migrated to new host) pkl package download package://example.com/a@1.0.0 package://example.com/b@1.0.0
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check each package URI resolves, collecting failures before the batch download
val failures = uris.groupBy { it.host }.mapValues { (host, us) -> probeAll(us) }.filterValues { it.isNotEmpty() } Try / catch
try {
pklCli.runPackageDownload(uris)
} catch (e: CliException) {
val failedUris = parseFailedUris(e.message ?: "")
failedUris.forEach { fixOrSkip(it) }
} Prevention
- Download packages one at a time when first migrating to a new registry.
- Monitor registry/network health before large batch downloads.
- Keep package URIs centralized so migrations are one-line changes.
When it happens
Trigger: Running `pkl package download pkgA pkgB ...` where two or more package downloads throw (network errors, bad URIs, checksum mismatches, missing versions).
Common situations: Batch downloads in CI after a registry outage; migrating packages to a new repository host where several URIs are wrong; air-gapped environments where all remote fetches fail.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- errors.values.single().message ?: "An unexpected error…
- Cannot download packages because no cache directory is…
- Failed to fetch dependency metadata for
- badHttpStatusCode
- badHttpStatusCode
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/2d51dc9f7b72560b.
Report an issue: GitHub.
Appendix: source
Thrown at pkl-cli/src/main/kotlin/org/pkl/cli/CliPackageDownloader.kt:51
}
val packageResolver = PackageResolver.getInstance(securityManager, httpClient, moduleCacheDir)
val errors = mutableMapOf<PackageUri, Throwable>()
for (pkg in packageUris) {
try {
packageResolver.downloadPackage(pkg, pkg.checksums, noTransitive)
} catch (e: Throwable) {
errors[pkg] = e
}
}
when (errors.size) {
0 -> return
1 ->
throw CliException(
errors.values.single().message
?: ("An unexpected error occurred: " + errors.values.single())
)
else ->
throw CliException(
buildString {
appendLine("Failed to download some packages.")
for ((uri, error) in errors) {
appendLine()
appendLine("Failed to download $uri because:")
appendLine("${error.message}")
}
}
)
}
}
}
View on GitHub (pinned to f3efcbfc9b)