nodeSetup: Couldn't follow symbolic link.
Hi,
Sometimes the nodeSetup task is failing with the error 'Couldn't follow symbolic link.' on osx.
Cleaning the .gradle directory fixes the issue.
> Task :myproject:nodeSetup FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':magicdraw-oslc-delegated-dialog:nodeSetup'.
> Couldn't follow symbolic link '/Users/thsoft/myproject/.gradle/nodejs/node-v20.11.1-darwin-x64/bin/npx'.
(This is exactly the same problem as https://github.com/srs/gradle-node-plugin/issues/190.)
Unfortunately I can't share my example and I can't reproduce this from a clean state, but I'll try to come up with a minimal example.
What version of the plugin are you using?
And when it fails, what does /Users/thsoft/myproject/.gradle/nodejs/node-v20.11.1-darwin-x64/bin/npx point to?
Thanks for reaching out!
Version:
plugins {
id("com.github.node-gradle.node") version "7.0.2"
}
Symlink target:
/Users/thsoft/myproject/.gradle/nodejs/node-v20.11.1-darwin-x64/bin/npx -> /Users/thsoft/myproject/.gradle/nodejs/node-v20.11.1-darwin-x64/lib/node_modules/npm/bin/npx-cli.js
We are facing the same issue:
> Task :pnpmSetup FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':pnpmSetup'.
> A problem occurred starting process 'command 'npm''
Environment (in case it makes a difference):
- macOS 15
- Gradle 8.10.2 running on Java 21
- nodejs is installed via homebrew
- /opt/homebrew/bin is on the PATH
- /opt/homebrew/bin/npm is a symlink to /opt/homebrew/Cellar/node/22.9.0/bin/npm
- /opt/homebrew/Cellar/node/22.9.0/bin/npm is a symlink to /opt/homebrew/lib/node_modules/npm/bin/npm-cli.js
This task produces the same error:
tasks.register<Exec>("npmVersion") {
environment = mapOf(Pair("PATH", "/opt/homebrew/bin"))
commandLine = listOf("npm", "--version")
}
I think you're hitting this Java 21 issue: https://github.com/gradle/gradle/issues/10483#issuecomment-2141505147 And this is probably something that only should be fixed in Gradle, but since it's Java 21 we might need to work around it in the plugin 🥲
For the download = false scenario relying on path should be absolutely fine, either your system knows where the thing is or you need to tell it
But in the case of download = true we know where the binary should be, and relying on PATH just means we might be picking up the wrong thing
same issue here since version 7.0.2 (also on 7.1.0) - on Java 21 AND 17!
We use download = true
Would disabling the gradle daemon workaround this issue?
https://docs.gradle.org/current/userguide/gradle_daemon.html#disable_for_a_build
I'd be curious to learn from others if that avoids this problem.
Not that I know of, and unless Gradle can work around this issue the only thing we can do is stop using PATH for download = true scenarios
Doing that makes perfect sense though, so if anyone is interested in looking into it I can do my best to help PRs
But I think this issue might be incidentally solved in #328 (though I've been unable to find the time to properly review it)