Gradle Plugin Fails on Windows #194

Closed
opened 2025-12-30 01:21:59 +01:00 by adam · 6 comments
Owner

Originally created by @jamesward on GitHub (Aug 1, 2024).

With a few projects which use the Pkl Gradle plugin that work on Linux, they fail on Windows with:

–– Pkl Error ––
Refusing to load module `C:/Users/james/Desktop/projects/hello-pkl/src/hello.pkl` because it does not match any entry in the module allowlist (`--allowed-modules`).

If I modify the pkl Gradle config to be:

pkl {
    evaluators {
        register("evalPkl") {
            allowedModules = listOf("")
            sourceModules.add(file("src/hello.pkl"))
            outputFile = layout.buildDirectory.file("hello.yaml")
            outputFormat = "yaml"
        }
    }
}

(overriding the allowedModules to be more permissive) I get:

–– Pkl Error ––
I/O error loading module `C:/Users/james/Desktop/projects/hello-pkl/src/hello.pkl`.
MalformedURLException: unknown protocol: c

So this looks like some weirdness with URIs and the Windows C: stuff.

Originally created by @jamesward on GitHub (Aug 1, 2024). With a few projects which use the Pkl Gradle plugin that work on Linux, they fail on Windows with: ``` –– Pkl Error –– Refusing to load module `C:/Users/james/Desktop/projects/hello-pkl/src/hello.pkl` because it does not match any entry in the module allowlist (`--allowed-modules`). ``` If I modify the `pkl` Gradle config to be: ``` pkl { evaluators { register("evalPkl") { allowedModules = listOf("") sourceModules.add(file("src/hello.pkl")) outputFile = layout.buildDirectory.file("hello.yaml") outputFormat = "yaml" } } } ``` (overriding the `allowedModules` to be more permissive) I get: ``` –– Pkl Error –– I/O error loading module `C:/Users/james/Desktop/projects/hello-pkl/src/hello.pkl`. MalformedURLException: unknown protocol: c ``` So this looks like some weirdness with URIs and the Windows `C:` stuff.
adam closed this issue 2025-12-30 01:21:59 +01:00
Author
Owner

@bioball commented on GitHub (Aug 1, 2024):

This was fixed in https://github.com/apple/pkl/pull/403.

For now, the workaround is to give Pkl a URI. For example:

sourceModules.add(file("src/hello.pkl").toURI())
@bioball commented on GitHub (Aug 1, 2024): This was fixed in https://github.com/apple/pkl/pull/403. For now, the workaround is to give Pkl a URI. For example: ```kt sourceModules.add(file("src/hello.pkl").toURI()) ```
Author
Owner

@jamesward commented on GitHub (Aug 2, 2024):

Oh awesome! Thank you!

@jamesward commented on GitHub (Aug 2, 2024): Oh awesome! Thank you!
Author
Owner

@jamesward commented on GitHub (Aug 2, 2024):

This might be fixed in #403 but even when turning the file into a URI, I still get the error:

Refusing to load module `C:/Users/james/Desktop/projects/hello-pkl/src/hello.pkl` because it does not match any entry in the module allowlist (`--allowed-modules`).

I've confirmed that file("src/hello.pkl").toURI() is:

file:/C:/Users/james/Desktop/projects/hello-pkl/src/hello.pkl

So maybe still something funky with the C:/ in there.

@jamesward commented on GitHub (Aug 2, 2024): This might be fixed in #403 but even when turning the file into a URI, I still get the error: ``` Refusing to load module `C:/Users/james/Desktop/projects/hello-pkl/src/hello.pkl` because it does not match any entry in the module allowlist (`--allowed-modules`). ``` I've confirmed that `file("src/hello.pkl").toURI()` is: ``` file:/C:/Users/james/Desktop/projects/hello-pkl/src/hello.pkl ``` So maybe still something funky with the `C:/` in there.
Author
Owner

@jamesward commented on GitHub (Aug 6, 2024):

Any other workaround ideas? Or any easy way to test the changes in #403 on Windows?

@jamesward commented on GitHub (Aug 6, 2024): Any other workaround ideas? Or any easy way to test the changes in #403 on Windows?
Author
Owner

@bioball commented on GitHub (Aug 6, 2024):

This was just fixed in release 0.26.3! Give that a shot and let us know if you have any issues.

@bioball commented on GitHub (Aug 6, 2024): This was just fixed in release 0.26.3! Give that a shot and let us know if you have any issues.
Author
Owner

@jamesward commented on GitHub (Aug 6, 2024):

It works now! Thank you!

@jamesward commented on GitHub (Aug 6, 2024): It works now! Thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#194