Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detection of unsupported environments #325

Open
chkpnt opened this issue Oct 11, 2024 · 1 comment
Open

Detection of unsupported environments #325

chkpnt opened this issue Oct 11, 2024 · 1 comment

Comments

@chkpnt
Copy link

chkpnt commented Oct 11, 2024

I'm using the following build.gradle.kts:

node {
    download = true
    version = "18.15.0"
    workDir = layout.buildDirectory.dir("nodejs")
}

val npmExec = if (System.getProperty("os.name").lowercase().contains("windows")) "/npm.cmd" else "/bin/npm"

spotless {
    isEnforceCheck = false

    format("javascript") {
        target("**/*.js", "**/*.json", "**/*.json5", "**/*.css")
        prettier(
            mapOf(
                "prettier" to "3.2.5",
                "prettier-plugin-multiline-arrays" to "3.0.4",
            )
        )
            .npmExecutable(
                "${
                    tasks.named<NpmSetupTask>("npmSetup").get().npmDir.get()
                }$npmExec"
            )
            .config(
                mapOf(
                    "printWidth" to 120,
                    "tabWidth" to 4,
                    "multilineArraysWrapThreshold" to 1,
                    "plugins" to listOf("prettier-plugin-multiline-arrays")
                )
            )
    }
}

When running spotlessCheck in an openjdk:11-image, I'm getting the following error:

/usr/bin/env: ‘node’: No such file or directory

#149 gave me the correct hint that the image is the culprit. After moving to eclipse-temurin:11-jdk (the openjdk-images are anyways deprecated), everything works fine.

But the issue doesn't seem to be related to musl, as openjdk:11 is based on Debian 11.4.

$ docker run -it --rm openjdk:11 ldd --version
ldd (Debian GLIBC 2.31-13+deb11u3) 2.31
[...]

eclipse-temurin:11-jdk is based on Ubuntu 24.04 and I haven't digged deeper, why I'm getting ‘node’: No such file or directory only on one system.

But as it took me some time 'til I figured out that the environment is the issue, I suggest gradle-node-plugin to detect problematic environments (musl et al) and print a warning.

@deepy
Copy link
Member

deepy commented Oct 14, 2024

I wonder if this is a bug or a timing issue, because testing node 18.15.0 on openjdk:11 (through docker with --platform linux/amd64) seems to work on my machine
But it's strange that it works with the new image (and with both being multi-platform that rules out platform shenanigans) 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants