Skip to content

use-node-version isn't respected if the first download fails #4104

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

Closed
gluxon opened this issue Dec 9, 2021 · 2 comments · Fixed by #4114
Closed

use-node-version isn't respected if the first download fails #4104

gluxon opened this issue Dec 9, 2021 · 2 comments · Fixed by #4114
Milestone

Comments

@gluxon
Copy link
Member

gluxon commented Dec 9, 2021

pnpm version: 6.23.6

Code to reproduce the issue:

Suppose use-node-version is set:

# .npmrc
use-node-version = 16.13.0

If you were to exit pnpm while it downloads that version:

❯ pnpm node
^C

pnpm doesn't appear to re-attempt that download. It defaults to the system version for all future calls:

❯ pnpm node --version
v17.2.0

The ~/Library/pnpm/nodejs/16.13.0 dir stays empty in that case:

❯ ls -l ~/Library/pnpm/nodejs/16.13.0/

❯

Running rm -rf ~/Library/pnpm/nodejs/16.13.0 gets things to work as expected again.

❯ rm -rf ~/Library/pnpm/nodejs/16.13.0

❯ pnpm node --version
v16.13.0

Expected behavior:

Should pnpm re-attempt to download node if it didn't finish or failed in the past?

❯ pnpm node
# Interrupted download
^C

❯ pnpm node --version
# Redownloads node...
v16.13.0

Alternatively pnpm could set up it's Node.js download more atomically. So ~/Library/pnpm/nodejs/<version> only gets created after the tarball/zip download is complete.

Actual behavior:

pnpm detects that the empty ~/Library/pnpm/nodejs/16.13.0 dir exists and assumes node is in that path. Wrong node version is used from that point on.

Additional information:

  • node -v prints: v17.2.0
  • Windows, macOS, or Linux?: macOS
@gluxon
Copy link
Member Author

gluxon commented Dec 9, 2021

Happy to help with this by the way. I think I'd mainly be curious which approach is preferred:

  1. Try to make the download more atomic so the dir check can stay the same.
  2. Extend the dir check by also seeing if node/node.exe exists.

@zkochan
Copy link
Member

zkochan commented Dec 9, 2021

yes, we should do this

Try to make the download more atomic so the dir check can stay the same.

use the path-temp lib. Same as we do it here:

const stage = pathTemp(path.dirname(newDir))

gluxon added a commit to gluxon/pnpm that referenced this issue Dec 13, 2021

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
fixes pnpm#4104
gluxon added a commit to gluxon/pnpm that referenced this issue Dec 13, 2021
gluxon added a commit to gluxon/pnpm that referenced this issue Dec 13, 2021
gluxon added a commit to gluxon/pnpm that referenced this issue Dec 15, 2021
gluxon added a commit to gluxon/pnpm that referenced this issue Dec 15, 2021
@zkochan zkochan added this to the v6.24 milestone Dec 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants