Skip to content

Detection of unsupported environments #325

Open

Description

@chkpnt

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.

Activity

  1. deepy commented on Oct 14, 2024

    @deepy
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions