-
-
Notifications
You must be signed in to change notification settings - Fork 9k
Add profile marker check #3613
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
base: master
Are you sure you want to change the base?
Add profile marker check #3613
Conversation
Allow users to prevent nvm from automatically updating their shell configuration files by adding '# nvm completions' comment. This follows the same pattern as bun where the presence of the marker indicates the user wants to manage the configuration manually. When '# nvm completions' is found in .zshrc/.bashrc, the installer will skip adding nvm initialization code, giving users more control over their shell configuration.
I'm a bit confused why a) this would be needed, when you can |
Thank you for the comment. @ljharb I understand that setting Ideally, I believe nvm shouldn't modify user profiles without explicit consent. But since this behavior is unlikely to be removed soon, providing a clear, documented, and non-destructive opt-out method like This approach has precedent (as in Happy to adjust the implementation or name of the marker if needed—my main concern is to make nvm a bit more respectful of user configurations by default. |
"I'm running an installer" is explicit consent, in all software i'm aware of. Directly below the place a user gets the install command, it says
I totally agree that the PROFILE workaround is not discoverable or ergonomic; but that's because you're basically the second user in 15 years who's asked about this or been even remotely concerned about it. I don't think "searching a profile file for a marker" is a reliable (and thus, ergonomic) approach either. Do you have an alternative suggestion? If so, perhaps an issue would make more sense to discuss it prior to a PR. |
Thanks for the detailed reply. @ljharb I agree that running an installer is a form of consent, but in practice, especially with shell one-liners ( You're right that this isn't a common complaint on GitHub. But I suspect that's partly because users either silently accept the modification or avoid using nvm altogether after one bad experience. This is a long-standing friction point that deserves more visibility. I submitted this PR primarily to spark this exact conversation. If you prefer to move the discussion to an issue first, I’m happy to open one and link back here. As for alternatives to a profile marker — I'm open to other opt-out mechanisms that:
Let me know if you'd prefer to continue in an issue — but I’d argue a PR is a perfectly valid way to initiate meaningful discussion, especially when the current behavior isn’t likely to change without code in front of us. |
We can certainly continue to discuss here, but code isn't really ever needed in order to decide a way forward :-) nvm currently installs with a one-liner, that will work in a headless environment or not. An env var, or a command line argument, are the only ways I'm aware of to modify a one-liner for a "from scratch" setup. I'm not sure why As for making assumptions about shell startup logic, I'm also not sure how that's avoidable - we already assume it's a POSIX-compliant shell (or zsh); in order to be automatically sourced in new shells, we have to live in a profile file somewhere; in order to find the right profile file, we have to make guesses and apply heuristics (something we already don't do a perfect job of). Do you have a concrete idea that would improve things? |
Thanks again — I really appreciate your detailed response. @ljharb I think we’re possibly talking past each other a little, so let me try to clarify my perspective: To me, the core issue isn’t about whether environment variables or command-line flags are more elegant — it’s about whether users can clearly and easily express intent to prevent profile modification, especially when they’re not aware it’s going to happen. The current mechanism assumes a level of understanding and intentionality that I don’t think reflects how many people use Yes, I agree that in some sense, running the installer is “consent,” but it’s blanket consent, and The idea behind the marker ( That said, if you’d prefer a more structured way like a |
Hmm. So, if I take your perspective, you'd prefer that the install script not touch profile files by default, with an easy way to opt in to it - iow, the "safe by default" perspective? In general I'm highly sympathetic to that, but I don't see "append some lines to the file" as particularly troublesome. Can you help me understand what problems it causes you to have it modify your zshrc by default? |
Thanks, yes — you got it right. I’m asking for a “safe by default” approach. @ljharb Here’s why I think changing
I’m not against helpful defaults — I just think editing user files should only happen if the user explicitly agrees. Tools like I’m open to other ways to solve this. I just want to protect users from surprise changes. |
Allow users to prevent nvm from automatically updating their shell configuration files by adding '# nvm completions' comment. This follows the same pattern as bun where the presence of the marker indicates the user wants to manage the configuration manually.
When '# nvm completions' is found in .zshrc/.bashrc, the installer will skip adding nvm initialization code, giving users more control over their shell configuration.
oven-sh/bun#7641
refs: #2153 #2076