Skip to content

Installer: display info about shell config file if unable to write to it.#3789

Open
MaddyGuthridge wants to merge 4 commits intonvm-sh:masterfrom
MaddyGuthridge:maddy-installer-check-ownership
Open

Installer: display info about shell config file if unable to write to it.#3789
MaddyGuthridge wants to merge 4 commits intonvm-sh:masterfrom
MaddyGuthridge:maddy-installer-check-ownership

Conversation

@MaddyGuthridge
Copy link

@MaddyGuthridge MaddyGuthridge commented Feb 20, 2026

In particular, this displays information about the config file's:

  • Owner
  • Permissions
  • Real path (if it is a symlink)

It then suggests that users may need to modify the file's permissions to grant $(whoami) write access.

Example outputs:

  • .zshrc is owned by root:
=> Appending nvm source string to /home/maddy/.zshrc
install.sh: line 479: /home/maddy/.zshrc: Permission denied
=> Failed to add nvm source string to /home/maddy/.zshrc
=> Info about /home/maddy/.zshrc:
   Owner: root (you are maddy)
   Permissions: -rw-r--r--
=> You may need to modify the file owner or permissions to grant maddy
   write access.
=> Or, you can the following lines to the file yourself:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
  • .zshrc is a symlink, and the target file does not have write permissions
=> Appending nvm source string to /home/maddy/.zshrc
install.sh: line 479: /home/maddy/.zshrc: Permission denied
=> Failed to add nvm source string to /home/maddy/.zshrc
=> Info about /home/maddy/.zshrc:
   Real path of /home/maddy/.zshrc: /home/maddy/.dotfiles/Configs/global/.zshrc
   Owner: maddy (you are maddy)
   Permissions: -r--r--r--
=> You may need to modify the file owner or permissions to grant maddy
   write access.
=> Or, you can the following lines to the file yourself:

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

Testing

  • I have tested this on NixOS 25.11, where it worked for the above cases, and for when there are no permission issues.
  • I have tested this on MacOS 26.3, where it has also worked correctly.
  • Should I write some integration tests for this? If so, can I get some info on how the testing works in this repo? Is it just a collection of shell scripts?

Additional notes

it.
In particular, this displays information about the config file's:
* Owner
* Permissions
* Real path (if it is a symlink)
@MaddyGuthridge MaddyGuthridge force-pushed the maddy-installer-check-ownership branch from ed7caff to ee9eed5 Compare February 20, 2026 11:09
@ljharb ljharb added the installing nvm Problems installing nvm itself label Feb 20, 2026
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is great! Could we add some unit tests for nvm_profile_info?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

installing nvm Problems installing nvm itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Install script: provide a nicer error if NVM cannot be added to the user's shell configuration due to permission issues

2 participants