Closed DonAtOCLC closed 11 months ago
There's a few things here at play, I've made doubly certain that the correct versions are being passed, and they are.
yarnSetup
is passed the expected .gradle\nodejs\node-v18.17.0-win-x64\npm.cmd
in my tests and I can confirm it working in your output as well: .gradle/nodejs/node-v8.10.0-linux-x64/bin/npm
Both npm.cmd and the shell script contain a similar setup, both will attempt to use node(with or without .exe)
and fall back to system node if it fails:
#Excerpt from npm shell script, from 9 but iirc it's been like this for a long while
NODE_EXE="$basedir/node.exe"
if ! [ -x "$NODE_EXE" ]; then
NODE_EXE="$basedir/node"
fi
if ! [ -x "$NODE_EXE" ]; then
NODE_EXE=node
fi
If you invoke npm version
it'll tell you which node version it used
I don't know why it's not working, it should be using the node next to it, can you try running ./.gradle/nodejs/node-v8.10.0-linux-x64/bin/node --version
and see what that outputs?
My immediate thought was that you're on a musl-based system like alpine, but afaik WSL2 is not
I had reason to revisit this scenario recently. The issue did turn out to be related to the Linux distro for the container, which was Alpine.
If the Alpine Linux instance has Node installed then the Gradle plugin ends up downloading the specified Node version but using the version installed via the package manager, apk add nodejs
. This turns out to be because the Node version installed by the Gradle plugin cannot be executed but the one installed via the package manager can.
I was seeing the following when attempting to execute the version of node that added by the Gradle plugin. The /bin
directly clearly did have the node
executable, but infuriatingly the shell kept on saying "not found".
/myproject/.gradle/nodejs/node-v17.9.1-linux-x64/bin # ./node --version /bin/sh: ./node: not found
After determining that the downloaded instance could not be executed, I decided to add a compatibility layer for glibc programs, as suggested by the Alpine documentation. With the compatibility layer added, the Gradle plugin works as expected. What confuses me is why Node installed via the package manager did not seem to need that compatibility layer.
I am having an issue where the yarnSetup task is using Node from the path instead of the downloaded instance of Node. While I don't think it should matter, the build environment is a container that is using an image that is based on an alpine image.
My build.gradle file contains the following configuration.
A build results in the following error:
And the aforementioned log contains:
The plugin is using the Node version on the path (v18) but the NPM version from the downloaded version (v8).