hasura/graphql-engine · error

error creating directory at %q: %w

Error message

error creating directory at %q: %w

What it means

moveToInstallDir creates the parent of the final install directory (e.g. {plugins}/{name}) with os.MkdirAll before staging the move, and that failed. Typical causes are permission denied, a blocking file at a path component, or a read-only filesystem.

Source

Thrown at cli/plugins/move.go:219

	for _, fo := range fos {
		err := moveFiles(fromDir, toDir, fo)
		if err != nil {
			return errors.E(op, fmt.Errorf("failed moving files: %w", err))
		}
	}

	return nil
}

// moveToInstallDir moves plugins from srcDir to dstDir (created in this method) with given FileOperation.
func moveToInstallDir(srcDir, installDir string, fos []FileOperation) error {
	var op errors.Op = "plugins.moveToInstallDir"

	installationDir := filepath.Dir(installDir)

	err := os.MkdirAll(installationDir, 0o755)
	if err != nil {
		return errors.E(op, fmt.Errorf("error creating directory at %q: %w", installationDir, err))
	}

	tmp, err := os.MkdirTemp("", "hasura-temp-move")
	if err != nil {
		return errors.E(op, fmt.Errorf("failed to find a temporary director: %w", err))
	}
	defer os.RemoveAll(tmp)

	if err = moveAllFiles(srcDir, tmp, fos); err != nil {
		return errors.E(op, fmt.Errorf("failed to move files: %w", err))
	}

	if err = renameOrCopy(tmp, installDir); err != nil {
		defer func() {
			os.Remove(installDir)
		}()

		return errors.E(

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Verify write access to the directory quoted in the error; chown -R or fix perms on the plugins root
  2. Point HOME/XDG_DATA_HOME (or the CLI's path override) at a writable location
  3. Delete any regular file occupying the directory path
  4. If the dir was created by root earlier, either fix ownership or run consistently as one user

Example fix

# before
sudo hasura plugins install my-plugin # root-owned dirs
# after
sudo chown -R $(id -u):$(id -g) ~/.local/share/hasura
hasura plugins install my-plugin
Defensive patterns

Strategy: try-catch

Validate before calling

if err := os.MkdirAll(filepath.Dir(installDir), 0o755); err != nil {
    return fmt.Errorf("pre-check: cannot create install dir: %w", err)
}

Try / catch

if err := installPlugin(p); err != nil {
    var perr *fs.PathError
    if errors.As(err, &perr) && os.IsPermission(perr) { /* chown/fix HOME, retry */ }
}

Prevention

When it happens

Trigger: os.MkdirAll(filepath.Dir(installDir)) failing: unwritable plugins install root, an existing regular file where a directory is expected, or a read-only mount.

Common situations: HOME or XDG_DATA_HOME redirected to an unwritable path; running as a user without rights to the pre-existing plugins dir (created earlier by root/sudo); container with a read-only volume for the install path.

Related errors


AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28). Data as JSON: /api/errors/0d2967d049bc5c5e. Report an issue: GitHub.