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
Allow comments in .nvmrc config file #3336
Comments
FYI, I prefer line and inline
If it turns out that |
As a work-around, devs can add comments anywhere after the first line of This is what one of my projects'
|
Additional lines will be used in the future for additional configuration, so if you put comments there things will break for you - don’t do that. |
That's why I called it a work-around while comments are still not officially supported. |
Regarding the OP, it's an rc file, so the only two options that would make sense are I think "shell" makes the most sense for nvm, so i'd say that "lines starting with |
PR #2288 has a discussion about comments in
.nvmrc
and I'm moving this to a proper issue so it doesn't get buried in the opinions about the code in that PR.Why support comments?
Projects should, when necessary, have comments in their configuration files like
.nvmrc
.The main reason I have comments in configuration files is to document bugs that force me to use a specific configuration option, .e.g. "Bug X causes Y so we set our config to Z as a work-around. [link to issue]" That kind of information needs to be right next to the configuration or someone (maybe even me!) will "fix it" later not realizing it causes a bug, e.g. "Huh, this file is out-of-date. The value of v14.13.1 should be updated to the latest v14.19.1. Oops. I broke something."
IMO, I think all configuration files should be able to have comments in them. Don't get me started on
.json
files for configuration.Current
.nvmrc
specificationI was looking at the code in NVM and noticed this line in the
nvm.sh
file:Only the first line in
.nvmrc
is ever used to determine the value ofNVM_RC_VERSION
. That means all the other lines in.nvmrc
could potentially be used for comments without any code changes. I tested this by creating a.nvmrc
file with an intentionally blank first line:And I got an error:
Warning: empty .nvmrc file found
And when I changed the file to:
The
nvm use
command reportedFound '.nvmrc' with version <14>
and ignored all other lines except the first.Right now, afaics, the entire
.nvmrc
syntax specification is:Plan for allowing comments in
.nvmrc
In this comment, the nvm maintainer said:
If we want to officially support comments, no code changes will be needed in this version of NVM. But we'll need to be mindful of how complex the code will need to be to support code comments in future versions of NVM.
What we need to discuss:
At a minimum, we need to support line comments. We need to decide if we optionally want to support inline comments and/or block comments.
Decide which comment format(s) to use. Examples:
Wikipedia has many other examples of code comment syntax.
Ensure the chosen comment format doesn't interfere with NVM's:
For example:
/* js-style */
block comments are INCOMPATIBLE with NVM's built-in alias,lts/*
, so we can't use that comment syntax.Document how comments work by adding it to the
.nvmrc
section of README.mdBoth 1 and 2 will affect how complicated the code will need to be when we need to implement comment parsing. It's clear the NVM maintainer wants very low complexity and maintenance costs. totally understandable.
The text was updated successfully, but these errors were encountered: