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

Node 15 upgrades npm to 7, which breaks prefix installs #123

Closed
boris-petrov opened this issue Oct 26, 2020 · 19 comments
Closed

Node 15 upgrades npm to 7, which breaks prefix installs #123

boris-petrov opened this issue Oct 26, 2020 · 19 comments

Comments

@boris-petrov
Copy link

When I set Node.js version 15.0.1 to be used, the yarnSetup task fails like so:

> Task :yarnSetup FAILED
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path /home/boris/project/.gradle/yarn/yarn-latest/lib
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, lstat '/var/lib/hudson/jobs/latest-git-build/workspace/backend/.gradle/yarn/yarn-latest/lib'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:

Using version 14.14.0 works fine. Any ideas?

@deepy
Copy link
Member

deepy commented Oct 26, 2020

Can confirm it's an issue with node 15:

$ .gradle/nodejs/node-v15.0.1-darwin-x64/bin/npm install --global --no-save --prefix hello yarn
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path /Users/alanor/projects/test/hello/lib
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, lstat '/Users/alanor/projects/test/hello/lib'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/alanor/.npm/_logs/2020-10-26T09_45_13_687Z-debug.log```

If I create hello/lib then it works.

Honestly I think this is something npm should be handling (and evidently used to since this works in npm 6.14.8 but not 7.0.3) but it shouldn't be too hard for us to work around, we just need to create that folder

@deepy deepy changed the title yarnSetup doesn't work with Node 15 Node 15 upgrades npm to 7, which breaks prefix installs Oct 26, 2020
@mswertz
Copy link

mswertz commented Nov 12, 2020

I have the same issue. Works when I set npmVersion to 6.14.8 but not when setting to 7.0.8. I am using release 2.2.4.

@deepy
Copy link
Member

deepy commented Nov 13, 2020

This is fixed in 3.0.0-rc4, awaiting CI results for 2.2.5

@NikolayMetchev
Copy link

for me it is breaking even with 3.0.0-rc4

npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path /Users/ntmetchev/Paxos/dev/metals/metals-web/node/yarn/yarn-v1.22.10/lib
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, lstat '/Users/ntmetchev/Paxos/dev/metals/metals-web/node/yarn/yarn-v1.22.10/lib'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/ntmetchev/.npm/_logs/2020-11-20T10_36_53_772Z-debug.log

> Task :metals-web:yarnSetup FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':metals-web:yarnSetup'.
> Process 'command '/Users/ntmetchev/Paxos/dev/metals/metals-web/node/node-v15.2.1-darwin-x64/bin/npm'' finished with non-zero exit value 254

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

@NikolayMetchev
Copy link

Also am I right in thinking that yarn_install has been renamed to yarn?

@deepy
Copy link
Member

deepy commented Nov 20, 2020

That's correct, the name for the YarnInstallTask is yarn, anything yarn_<foo> is considered an ad-hoc task and handled by the rule that's there for convenience.

But the yarnSetup task failing is strange, the directory is being created a little bit before the task itself is run, I've been swamped at work but hopefully I can test this a little later today.

@NikolayMetchev
Copy link

Thanks @deepy Perhaps it is worth putting the release notes for 3.0 that the name of the task has changed, it is a breaking change.

@deepy
Copy link
Member

deepy commented Nov 20, 2020

Oh it hasn't changed, when yarn support was initially added 4 years ago it was with the same name, but I do know that a lot of people previously missed npmInstall and set up their own npm_install (and running it twice as a result)

But I realize now that when I added a clarification in the documentation I forgot to account for the same issue with yarn (see docs/usage.md#executing-npm-tasks), I'll update that after I look at this issue

@deepy
Copy link
Member

deepy commented Nov 21, 2020

I've tried to reproduce this, but on rc4 I can't get the YarnInstallTask to fail, I'm using the examples from the examples folder with the following modification(s)

node {
    version = '15.0.1'
    download = true
}

running ..\..\gradlew yarn works as expected

BUILD SUCCESSFUL in 58s
9 actionable tasks: 9 executed

@NikolayMetchev
Copy link

Sorry for the slow response. Been busy. Here is the file that is failing for me with Gradle 6.7.1 on MacOS:

plugins {
  id "base"
  id "com.github.node-gradle.node" version "3.0.0-rc4"
}

node {
  // Version of node to use.
  version = '15.2.1'

  // Version of Yarn to use.
  yarnVersion = '1.22.10'

  // Base URL for fetching node distributions (change if you have a mirror).
  distBaseUrl = 'https://nodejs.org/dist'

  // If true, it will download node using above parameters.
  // If false, it will try to use globally installed node.
  download = true

  // Set the work directory for unpacking node
  workDir = file("${project.projectDir}/node")

  // Set the work directory for Yarn
  yarnWorkDir = file("${project.projectDir}/node/yarn")

  // Set the work directory where node_modules should be located
  nodeModulesDir = file("${project.projectDir}")
}

@NikolayMetchev
Copy link

(venv) ➜ temp gradle yarn
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

Task :yarnSetup
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path /Users/ntmetchev/Paxos/dev/temp/node/yarn/yarn-v1.22.10/lib
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, lstat '/Users/ntmetchev/Paxos/dev/temp/node/yarn/yarn-v1.22.10/lib'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/ntmetchev/.npm/_logs/2020-11-24T09_51_12_416Z-debug.log

Task :yarnSetup FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':yarnSetup'.

Process 'command '/Users/ntmetchev/Paxos/dev/temp/node/node-v15.2.1-darwin-x64/bin/npm'' finished with non-zero exit value 254

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 13s
2 actionable tasks: 2 executed
(venv) ➜ temp

@deepy
Copy link
Member

deepy commented Nov 24, 2020

Oh this is sneaky, not sure how it worked on my machine but the directory being created is node/yarn/yarn-v1.22.10/ and the one necessary is node/yarn/yarn-v1.22.10/lib

@NikolayMetchev
Copy link

You probably already had that directory when you ran it.

stuartraetaylor added a commit to stuartraetaylor/gradle-node-plugin that referenced this issue Nov 24, 2020
3.0.0-rc4 - kotlin rewrite, lazy configuration, api changes, proxy fixes.
* Plugin rewritten in Kotlin (issue node-gradle#17) (thanks mikejhill for the pull request)
* Improved Kotlin DSL support
* Upgraded default Node.js version to 12.18.1 (bundled with npm 6.14.5), the latest LTS version
* Lazy configuration support
* Fix some remaining input/output declaration issues (issue node-gradle#34)
* Gradle 5.6.4+ support (instead of Gradle 5.0.0+ before)
* Node.js 10+ support (issue node-gradle#100)
* Use http:// for both HTTP and HTTPS_PROXY
* No longer configures proxy if there's already proxy settings present
* Support for npm 7+ node-gradle#123

See CHANGELOG for full details and upgrade instructions.
@deepy
Copy link
Member

deepy commented Nov 27, 2020

I've created #127 which should fix this and there's tests that prove it this time 😅

@NikolayMetchev
Copy link

@deepy Thanks, much appreciated. Let me know when it has been released so I can test it as well.

@deepy
Copy link
Member

deepy commented Nov 27, 2020

If you clone the branch you can test it in your project with ./gradlew --include-build ../gradle-node-plugin

@NikolayMetchev
Copy link

@deepy I just tested it as you described and that branch is working for me. Thank you.

@deepy
Copy link
Member

deepy commented Nov 30, 2020

Great! I'll merge and create a release this evening so by tomorrow it should be fixed :-)

@deepy deepy closed this as completed in 9f5daed Nov 30, 2020
@deepy
Copy link
Member

deepy commented Nov 30, 2020

3.0.0-rc5 is out now

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

4 participants