Because of this, if the Pkl class is loaded by a different classloader compared to the one which contains JDK classes, which is totally possible in certain scenarios (e.g. with Gradle), then this resource resolution will fail.
The solution is to switch the javaClass target to this@CliCommand to load the resource using the classloader which loaded the jar with the CliCommand class.
Originally created by @netvl on GitHub (Sep 4, 2025).
In this piece of code: https://github.com/apple/pkl/blob/a66ac0eb35f987b90b9f92e3f4efa5804a7ff798/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/CliCommand.kt#L208-L225
the `org/pkl/commons/cli/PklCARoots.pem` resource is resolved relatively to the classloader associated with the class returned by `javaClass`. However, since this is an extension method for `HttpClient.Builder`, it means calling `javaClass` on the builder instance, which is actually defined in the system classpath.
Because of this, if the Pkl class is loaded by a different classloader compared to the one which contains JDK classes, which is totally possible in certain scenarios (e.g. with Gradle), then this resource resolution will fail.
The solution is to switch the `javaClass` target to `this@CliCommand` to load the resource using the classloader which loaded the jar with the `CliCommand` class.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @netvl on GitHub (Sep 4, 2025).
In this piece of code: https://github.com/apple/pkl/blob/a66ac0eb35f987b90b9f92e3f4efa5804a7ff798/pkl-commons-cli/src/main/kotlin/org/pkl/commons/cli/CliCommand.kt#L208-L225
the
org/pkl/commons/cli/PklCARoots.pemresource is resolved relatively to the classloader associated with the class returned byjavaClass. However, since this is an extension method forHttpClient.Builder, it means callingjavaClasson the builder instance, which is actually defined in the system classpath.Because of this, if the Pkl class is loaded by a different classloader compared to the one which contains JDK classes, which is totally possible in certain scenarios (e.g. with Gradle), then this resource resolution will fail.
The solution is to switch the
javaClasstarget tothis@CliCommandto load the resource using the classloader which loaded the jar with theCliCommandclass.