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

Increase specificity of .nvmrc version #57648

Closed
wants to merge 1 commit into from

Conversation

vcanales
Copy link
Member

@vcanales vcanales commented Jan 8, 2024

What?

Specify minimum minor version of node on .nvmrc to match the engine specified on package.json.

Why?

If I have previously installed a lower node version than what's required in package.json, using nvm use will succeed, but npm i will fail. This changes moves the failure in the chain, so that it will be nvm that'll let you know that you have to install a newer version of node.

Before:

➜  gutenberg git:(trunk) nvm use
Found 'gutenberg/.nvmrc' with version <20>
Now using node v20.9.0 (npm v10.1.0)
➜  gutenberg git:(trunk) npm i
npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: gutenberg@17.4.1
npm ERR! notsup Not compatible with your version of node/npm: gutenberg@17.4.1
npm ERR! notsup Required: {"node":">=20.10.0","npm":">=10.2.3"}
npm ERR! notsup Actual:   {"npm":"10.1.0","node":"v20.9.0"}

After:

➜  gutenberg git:(increase-specificity-of-nvm-version) nvm use            
Found 'gutenberg/.nvmrc' with version <20.10>
N/A: version "v20.10" is not yet installed.

You need to run `nvm install` to install and use the node version specified in `.nvmrc`.

Trac ticket: https://core.trac.wordpress.org/ticket/59663.

@vcanales vcanales added the [Type] Build Tooling Issues or PRs related to build tooling label Jan 8, 2024
@vcanales vcanales requested a review from desrosj January 8, 2024 15:30
@desrosj
Copy link
Contributor

desrosj commented Jan 8, 2024

Hey @vcanales! Thanks for this one. I've gone and added the corresponding Trac ticket to the PR description so that this shows up there. There's already a suggestion and a PR there for this. I expressed some thoughts around the change in the ticket, and working to gather a bit more info before making a decision. But wanted to acknowledge that I saw this!

@vcanales
Copy link
Member Author

vcanales commented Jan 8, 2024

Thanks for taking a look, and for the extra context. I'll echo the questions that @kraftbj made over there, since I have the same ones:

IMO, if the version in nvmrc could be met by versions not meeting package.json, one or the other should be adjusted (e.g. why 20.10 vs 20.x as the minimum? Is there a functional reason why 20.10 is the minimum of the LTS?)

@desrosj
Copy link
Contributor

desrosj commented May 7, 2024

Is this still a problem? The corresponding Core ticket has been closed out.

This is really only a problem when the versions defined in engines is bumped to the latest version at the time because some contributors will not always have the latest release. Now that a bit of time has passed and the latest is now 20.12.2, this is less likely to be encountered.

Copy link

github-actions bot commented May 7, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: vcanales <vcanales@git.wordpress.org>
Co-authored-by: desrosj <desrosj@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@vcanales
Copy link
Member Author

While it's true that it's less likely to happen, I don't see why we wouldn't want to keep .nvmrc and package.json versions in more precise sync.

@desrosj
Copy link
Contributor

desrosj commented May 14, 2024

The value in engines is not regularly updated. If we define 20.10 in the .nvmrc file, then contributors would be unable to use nvm to easily run the latest version (nvm install would be stuck in the 12.10.x range) unless we continuously update the version in the file. Instead of creating that maintenance burden, just specifying 20 fixes that with the possibility of some issues initially when the project bumps the minimum required version.

@vcanales vcanales closed this May 22, 2024
@vcanales vcanales deleted the increase-specificity-of-nvm-version branch May 22, 2024 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Build Tooling Issues or PRs related to build tooling
2 participants