The nvm install script fails with curl error 23 and Permission denied
Fix it fast
Most common cause, 1 of 2curl is the snap package, and snaps cannot write to hidden folders in $HOME
Replace the snap with Ubuntu's own curl package, or install git so the script clones instead of downloading with curl.
sudo snap remove curl
sudo apt update && sudo apt install curl git
hash -r
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bashShort answer
curl error 23 is a local write error: curl fetched nvm but could not save it into ~/.nvm. With nvm 0.41 on Ubuntu 24.04 the usual reasons are a snap curl, which cannot write to hidden home folders, or a ~/.nvm owned by root after an earlier sudo run. Use apt's curl or install git, then rerun without sudo.
Which cause do you have?
Check which curl runs, whether git is present, and who owns the nvm folder. A path under /snap/bin with no git is cause 1; a ~/.nvm owned by root is cause 2.
command -v curl git
snap list curl
ls -ld ~/.nvmThen find the line you see in this list and open its fix:
- 1curl is the snap package, and snaps cannot write to hidden folders in $HOME
command -v curl prints /snap/bin/curl, snap list shows curl, and git is not installed - 2~/.nvm or the chosen NVM_DIR is not writable by your user
ls -ld ~/.nvm shows root as the owner, usually after the script was once run with sudo, while curl itself is /usr/bin/curl
What does the error look like?
curl: (23) Failure writing output to destinationWarning: Failed to open the file /home/user/.nvm/nvm.sh.download: Permission denied
Cause 1 of 2
curl is the snap package, and snaps cannot write to hidden folders in $HOME
You seecommand -v curl prints /snap/bin/curl, snap list shows curl, and git is not installed
Check
The nvm installer clones with git when git exists and only falls back to curl or wget when it does not. In that fallback, curl saves nvm.sh into ~/.nvm. The curl snap is strictly confined and reaches your home only through the home interface, which covers non-hidden files only, so writing into a dot-folder fails and curl reports error 23.
snap connections curlFix
Replace the snap with Ubuntu's own curl package, or install git so the script clones instead of downloading with curl. Then run the installer again as your normal user.
sudo snap remove curl
sudo apt update && sudo apt install curl git
hash -r
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bashVerify
command -v curl now prints /usr/bin/curl, the script ends without errors, and a new shell knows the nvm command.
command -v nvm && nvm --versionConfirmed by snapcraft.io
Cause 2 of 2
~/.nvm or the chosen NVM_DIR is not writable by your user
You seels -ld ~/.nvm shows root as the owner, usually after the script was once run with sudo, while curl itself is /usr/bin/curl
Check
curl's manual defines exit code 23 as a write error: it could not write data to a local file system. The installer writes into NVM_DIR when that variable is set, otherwise into ~/.nvm, so a folder your account cannot write to stops it even though the network part worked.
touch ~/.nvm/write-test && rm ~/.nvm/write-testFix
Give the folder back to your user and run the installer without sudo. If you set NVM_DIR yourself, point it at a folder you own and leave off any trailing slash, as the nvm README asks.
sudo chown -R "$USER":"$USER" ~/.nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bashVerify
The write test succeeds and the installer prints no curl error; open a new terminal and nvm loads.
ls -l ~/.nvm/nvm.shConfirmed by curl.se
How do I stop it coming back?
- On Ubuntu servers and CI images, install curl and git with apt in the base image before running any install script.
- Never pipe the nvm installer into sudo bash; nvm lives in your user's home and needs no root.
- Pin the nvm version in your setup script (v0.41.0 today) so reruns fetch the same installer.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.