hasura/graphql-engine · error

failed to find a temporary director: %w

Error message

failed to find a temporary director: %w

What it means

moveToInstallDir stages files through a temp dir created with os.MkdirTemp("", "hasura-temp-move"); creation failed. The system temp directory (TMPDIR) is missing, unwritable, or exhausted (inode/space limits).

Source

Thrown at cli/plugins/move.go:224

	}

	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(
			op,
			fmt.Errorf("could not rename/copy directory %q to %q: %w", tmp, installDir, err),
		)
	}

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Check TMPDIR/TEMP/TMP env vars point to an existing writable directory
  2. Verify space and inodes on the temp filesystem (df -h /tmp; df -i /tmp)
  3. Fix permissions on /tmp or remount it writable
  4. Set TMPDIR to a roomier writable location and retry the install

Example fix

# before
TMPDIR=/nonexistent hasura plugins install p
# after
mkdir -p ~/tmp && TMPDIR=~/tmp hasura plugins install p
Defensive patterns

Strategy: validation

Validate before calling

tmp := os.Getenv("TMPDIR")
if tmp == "" { tmp = "/tmp" }
if fi, err := os.Stat(tmp); err != nil || !fi.IsDir() {
    return errors.New("TMPDIR invalid; set a writable temp dir")
}

Try / catch

if err := installPlugin(p); err != nil && strings.Contains(err.Error(), "temporary director") {
    // set TMPDIR to a writable location and retry
}

Prevention

When it happens

Trigger: os.MkdirTemp cannot create a directory in TMPDIR: TMPDIR points to a nonexistent/unwritable path, /tmp is mounted noexec/read-only for the user, or disk/inodes are full.

Common situations: Containers with tiny or read-only /tmp; TMPDIR misconfigured in CI; shared host with /tmp cleanup daemons; disk full during plugin install.

Related errors


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