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

[readme] Update shell profile file install notes #2241

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

asadakbar
Copy link
Contributor

@asadakbar asadakbar commented Jun 20, 2020

  • Changes the suggested shell when running the install script to $SHELL
    which will return the default shell.
  • Adds a note for how to fix the issue when the install script is not
    updating the correct profile file.
  • Reorders the list of profile files to match the order of files the install script looks for.

NOTES ON CHANGES:
This documentation change is to help users who are finding that the install script is not updating the correct shell profile file. $SHELL will return the path to the default shell used, which will set the environment variables used by the install script to decide which profile file to update. There are reports of users not sure why their preferred profile file is not being updated here #2196.

I suspect that many of these are from people running the given curl command, which currently pipes the install script into bash explicitly, even if the user has zsh or another shell as their default. This will especially bite MacOS Catalina users who now have zsh as their default shell.

There is also a way for users to explicitly set which profile file to change by the install script, which some users have asked for not knowing it already exists. Here #2188, #869 . This lets them know how to do that.

CAVEATS:
I would prefer to use an variable like $0 instead of $SHELL as $SHELL does not return the currently used shell, but the default shell. The reason why $0 can't be used is that it returns the current shell with a - in front of it. Once you switch to another shell and then back, the - is gone, but its there for all uses before switching to another shell and back. $SHELL however is better than the current example which states bash explicitly.

Also, it would be better for the install script to be a smarter about which profile file to change. Right now it is using the existence of $BASH_VERSION, .bashrc, .bash_profile, $ZSH_VERSION, .zshrc, and then .profile, in that order, to decide. It could instead look at which shell is being used and then set the corresponding profile file, through something like $SHELL or $0. I'm not versed in shell script so will leave those changes to someone with more experience.

* Adds a note for how to fix the issue when the install script is not   updating the correct profile file.
@sladyn98
Copy link
Contributor

@ljharb Would we want to include this, since we determined that piping through other shells might break backward compatibility.

@ljharb ljharb marked this pull request as draft April 7, 2021 15:43
@ljharb ljharb force-pushed the master branch 2 times, most recently from c6cfc3a to c20db2a Compare June 10, 2024 18:13
@ljharb ljharb changed the title [Docs] Update README for install notes [readme] Update shell profile file install notes Feb 3, 2025
@ljharb ljharb marked this pull request as ready for review February 3, 2025 21:35
@ljharb ljharb added informational installing nvm: profile detection Issues with nvm's own install script, related to figuring out the right profile file. labels Feb 3, 2025
@ljharb ljharb merged commit 9bcbbef into nvm-sh:master Feb 3, 2025
169 of 171 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
informational installing nvm: profile detection Issues with nvm's own install script, related to figuring out the right profile file.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants