Error while piping nvm to zsh shell during installation

Hi everyone,

I am using Ubuntu 22.04 and on zsh shell.

While following the instructions to Install NodeJS, npm, and Docker as part of the CHT Core dev environment setup I ran into an issue.

I ran the first command and that worked as expected.

export nvm_version=`curl -s https://api.github.com/repos/nvm-sh/nvm/releases/latest | jq -r .name`

However, when I ran the second command

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/$nvm_version/install.sh | $SHELL
. ~/.$(basename $SHELL)rc

I got the following error in my terminal

Error: the install instructions explicitly say to pipe the install script to `bash`; please follow them

If I understand correctly, the $(basename $SHELL) part of the second command is designed to work both for bash and zsh. However, it did not work for me despite several tries.

4 Likes

My workaround to the issue was to do as the error message suggested and pipe it to bash directly with

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/$nvm_version/install.sh | bash

Then I copied the following lines to my ~/.zshrc.

echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.zshrc
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.zshrc
echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"' >> ~/.zshrc

with that I have NodeJS 16.20.2 and nvm version 8.19.4 working in my zsh

This made me laugh. Passive aggressive error messages :smiley: