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

Ignores $ZDOTDIR when installing #3128

Closed
nea89o opened this issue Jun 7, 2023 · 5 comments
Closed

Ignores $ZDOTDIR when installing #3128

nea89o opened this issue Jun 7, 2023 · 5 comments
Labels
installing nvm: profile detection Issues with nvm's own install script, related to figuring out the right profile file. pull request wanted This is a great way to contribute! Help us out :-D shell: zsh

Comments

@nea89o
Copy link

nea89o commented Jun 7, 2023

How did you install nvm?

install script in readme

What steps did you perform?

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

What happened?

A new file at ~/.zshrc was created and populated with

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

What did you expect to happen?

For the file at $ZDOTDIR/.zshrc to be populated (in my case ~/.config/zsh/.zshrc)

Is there anything in any of your profile files that modifies the PATH?

/etc/zsh/zshenv:

export ZDOTDIR="$HOME"/.config/zsh
@ljharb
Copy link
Member

ljharb commented Jun 7, 2023

what is ZDOTDIR? I've never heard of that.

@ljharb ljharb added shell: zsh needs followup We need some info or action from whoever filed this issue/PR. installing nvm: profile detection Issues with nvm's own install script, related to figuring out the right profile file. labels Jun 7, 2023
@nea89o
Copy link
Author

nea89o commented Jun 7, 2023

Quoting man 1 zsh:

STARTUP/SHUTDOWN FILES
       Commands  are  first  read from /etc/zsh/zshenv; this cannot be overridden.  Subsequent behaviour is modified by the RCS and GLOBAL_RCS options; the former
       affects all startup files, while the second only affects global startup files (those shown here with an path starting with a /).  If one of the options  is
       unset  at  any  point,  any subsequent startup file(s) of the corresponding type will not be read.  It is also possible for a file in $ZDOTDIR to re-enable
       GLOBAL_RCS. Both RCS and GLOBAL_RCS are set by default.

       Commands are then read from $ZDOTDIR/.zshenv.  If the shell is a login shell, commands are read from /etc/zsh/zprofile and then $ZDOTDIR/.zprofile.   Then,
       if  the  shell is interactive, commands are read from /etc/zsh/zshrc and then $ZDOTDIR/.zshrc.  Finally, if the shell is a login shell, /etc/zsh/zlogin and
       $ZDOTDIR/.zlogin are read.

       When a login shell exits, the files $ZDOTDIR/.zlogout and then /etc/zsh/zlogout are read.  This happens with either an explicit exit via the exit or logout
       commands, or an implicit exit by reading end-of-file from the terminal.  However, if the shell terminates due to exec'ing another process, the logout files
       are not read.  These are also affected by the RCS and GLOBAL_RCS options.  Note also that the RCS option affects the saving of history files, i.e.  if  RCS
       is unset when the shell exits, no history file will be saved.

       If ZDOTDIR is unset, HOME is used instead.  Files listed above as being in /etc may be in another directory, depending on the installation.

       As  /etc/zsh/zshenv  is  run  for all instances of zsh, it is important that it be kept as small as possible.  In particular, it is a good idea to put code
       that does not need to be run for every single shell behind a test of the form `if [[ -o rcs ]]; then ...' so that it will not be executed when zsh  is  in‐
       voked with the `-f' option.

       Any of these files may be pre-compiled with the zcompile builtin command (see zshbuiltins(1)).  If a compiled file exists (named for the original file plus
       the .zwc extension) and it is newer than the original file, the compiled file will be used instead.

Basically a systemwide property to change the save location of your ~/.zshrc

@ljharb
Copy link
Member

ljharb commented Jun 7, 2023

ok, so it seems like if in the install script, instead of looking for $HOME/.zshrc, we did ${ZDOTDIR:-HOME}/.zshrc (or something) that it would work the same for anyone without that set, and would then work properly for you?

@nea89o
Copy link
Author

nea89o commented Jun 7, 2023

Yep, ZDOTDIR is just for overriding the location of the .zshrc file, the actual .zshrc file works the same.

@ljharb ljharb added pull request wanted This is a great way to contribute! Help us out :-D and removed needs followup We need some info or action from whoever filed this issue/PR. labels Jun 7, 2023
@ljharb
Copy link
Member

ljharb commented Jun 7, 2023

Then all that's needed is a minor change, and a test :-) feel free to submit a PR if you have the time!

menaechmi added a commit to menaechmi/nvm that referenced this issue Nov 6, 2024
menaechmi added a commit to menaechmi/nvm that referenced this issue Nov 7, 2024
menaechmi added a commit to menaechmi/nvm that referenced this issue Nov 7, 2024
menaechmi added a commit to menaechmi/nvm that referenced this issue Nov 7, 2024
@ljharb ljharb closed this as completed in cd22c84 Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installing nvm: profile detection Issues with nvm's own install script, related to figuring out the right profile file. pull request wanted This is a great way to contribute! Help us out :-D shell: zsh
Projects
None yet
Development

No branches or pull requests

2 participants