Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Node.js, PHP and APIs

The nvm install script fails with curl error 23 and Permission denied

Your error

curl: (23) Failure writing output to destination1 more line it can show

Fix it fast

Most common cause, 1 of 2

curl 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.

Fix
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 | bash
Did this fix it?
Full steps for this cause: check, fix, verify

Short 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.

  • Applies to nvm v0.41.0, Ubuntu 24.04 LTS, curl 8.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

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.

Run this first
command -v curl git
snap list curl
ls -ld ~/.nvm

Then find the line you see in this list and open its fix:

  1. 1curl is the snap package, and snaps cannot write to hidden folders in $HOMEcommand -v curl prints /snap/bin/curl, snap list shows curl, and git is not installed
  2. 2~/.nvm or the chosen NVM_DIR is not writable by your userls -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 destination
  • Warning: 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.

Check
snap connections curl

Fix

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.

Fix
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 | bash

Verify

command -v curl now prints /usr/bin/curl, the script ends without errors, and a new shell knows the nvm command.

Verify
command -v nvm && nvm --version

Confirmed by snapcraft.io

Did this fix it?

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.

Check
touch ~/.nvm/write-test && rm ~/.nvm/write-test

Fix

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.

Fix
sudo chown -R "$USER":"$USER" ~/.nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash

Verify

The write test succeeds and the installer prints no curl error; open a new terminal and nvm loads.

Verify
ls -l ~/.nvm/nvm.sh

Confirmed by curl.se

Did this fix it?

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.

Which stack is behind this page?

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.