node-gradle / node-gradle/gradle-node-plugin

Detection of unsupported environments

Open
#325 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Groovy
Stars
677
Forks
120
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The report provides a build.gradle.kts configuration and the spotlessCheck task, with openjdk:11 as the failing environment and eclipse-temurin:11-jdk as a comparison. Reproduce the failure in the referenced container images, then define detection and warning behavior for unsupported environments such as musl; done means users receive a clear warning instead of the unexplained node error.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, kotlin, nodejs
Domain
build-system, devops
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.