asdf-vm/asdf · error

unable to create download dir: %w

Error message

unable to create download dir: %w

What it means

installtest.InstallOneVersion prepares a sandboxed install to test a plugin version: it creates ASDF_DOWNLOAD_PATH via os.MkdirAll before running the plugin's download/install callbacks. If the directory cannot be created, the wrapped error "unable to create download dir" is returned.

Source

Thrown at internal/installtest/installtest.go:46

	err := plugin.Exists()
	if err != nil {
		return err
	}

	downloadDir := DownloadPath(conf, plugin, version)
	installDir := InstallPath(conf, plugin, version)

	env := map[string]string{
		"ASDF_INSTALL_TYPE":    versionType,
		"ASDF_INSTALL_VERSION": version,
		"ASDF_INSTALL_PATH":    installDir,
		"ASDF_DOWNLOAD_PATH":   downloadDir,
		"ASDF_CONCURRENCY":     "1",
	}

	err = os.MkdirAll(downloadDir, 0o777)
	if err != nil {
		return fmt.Errorf("unable to create download dir: %w", err)
	}

	err = plugin.RunCallback("download", []string{}, env, &stdOut, &stdErr)
	if _, ok := err.(plugins.NoCallbackError); err != nil && !ok {
		return fmt.Errorf("failed to run download callback: %w", err)
	}

	err = os.MkdirAll(installDir, 0o777)
	if err != nil {
		return fmt.Errorf("unable to create install dir: %w", err)
	}

	err = plugin.RunCallback("install", []string{}, env, &stdOut, &stdErr)
	if err != nil {
		return fmt.Errorf("failed to run install callback: %w", err)
	}

	return nil

View on GitHub (pinned to 074a1722ca)

Solutions

  1. Check and fix permissions on the asdf data dir (typically ~/.asdf): `ls -ld ~/.asdf` and `chown`/`chmod` as needed.
  2. Free disk space or raise quota if the filesystem is full.
  3. Remove any conflicting file at the download path so MkdirAll can create the directory.
  4. Avoid running asdf with sudo, which creates root-owned dirs; fix ownership of previously created dirs.

Example fix

# before (root-owned ~/.asdf)
sudo asdf install nodejs 20.11.0
# after
sudo chown -R $(whoami) ~/.asdf
asdf install nodejs 20.11.0
Defensive patterns

Strategy: validation

Validate before calling

test -w "${ASDF_DATA_DIR:-$HOME/.asdf}" || { echo "asdf data dir not writable"; exit 1; }
df -h "${ASDF_DATA_DIR:-$HOME/.asdf}" | awk 'NR==2 && $5+0 >= 100 {exit 1}'

Try / catch

if ! asdf install "$PLUGIN" "$VER" 2>&1 | grep -q 'unable to create download dir'; then :; else
  sudo chown -R "$(whoami)" "${ASDF_DATA_DIR:-$HOME/.asdf}" && asdf install "$PLUGIN" "$VER"
fi

Prevention

When it happens

Trigger: Running `asdf install <plugin> <version>` (which exercises install tests) where the download path's parent is unwritable, the disk is full, a file exists where the directory should be, or a leftover directory has wrong permissions.

Common situations: Read-only ASDF_DATA_DIR (e.g. ~/.asdf mounted read-only in containers/CI); permission changes after running asdf as root/sudo previously; disk quota exceeded.

Related errors


AI-assisted analysis of asdf-vm/asdf@074a1722ca (2026-08-30). Data as JSON: /api/errors/c5e7781b1b261e3f. Report an issue: GitHub.