goreleaser/goreleaser · error

failed to make dir for artifact: %w

Error message

failed to make dir for artifact: %w

What it means

While staging artifacts (binaries, archives) into the Docker build context temp directory, goreleaser calls os.MkdirAll on the artifact's target directory. This error means that directory creation failed, so the artifact cannot be copied in and the docker build cannot proceed. It wraps the underlying OS error.

Source

Thrown at internal/pipe/docker/docker.go:255

	if err := gio.Copy(
		docker.Dockerfile,
		filepath.Join(tmp, "Dockerfile"),
	); err != nil {
		return fmt.Errorf("failed to copy dockerfile: %w", err)
	}

	for _, file := range docker.Files {
		if err := os.MkdirAll(filepath.Join(tmp, filepath.Dir(file)), 0o755); err != nil {
			return fmt.Errorf("failed to copy extra file '%s': %w", file, err)
		}
		if err := gio.Copy(file, filepath.Join(tmp, file)); err != nil {
			return fmt.Errorf("failed to copy extra file '%s': %w", file, err)
		}
	}
	for _, art := range artifacts {
		target := filepath.Join(tmp, art.Name)
		if err := os.MkdirAll(filepath.Dir(target), 0o755); err != nil {
			return fmt.Errorf("failed to make dir for artifact: %w", err)
		}

		if err := gio.Copy(art.Path, target); err != nil {
			return fmt.Errorf("failed to copy artifact: %w", err)
		}
	}

	buildFlags, err := processBuildFlagTemplates(ctx, docker)
	if err != nil {
		return err
	}

	log.Info("building docker image")
	if err := dockerBuild(ctx, docker, tmp, images, buildFlags); err != nil {
		if isFileNotFoundError(err.Error()) {
			var files []string
			_ = filepath.Walk(tmp, func(_ string, info fs.FileInfo, _ error) error {
				if info.IsDir() {

View on GitHub (pinned to f5edd73956)

Solutions

  1. Inspect the wrapped error to determine if it's a permission, ENOSPC, or path issue.
  2. Ensure artifact names/templates yield simple relative paths without exotic directory components.
  3. Free disk space or point TMPDIR at a writable location and rerun.
Defensive patterns

Strategy: validation

Validate before calling

df, err := checkDiskSpace(os.TempDir())
if err != nil || df.Available < 512*1024*1024 {
    return errors.New("insufficient space in TMPDIR for docker build context")
}

Try / catch

if err != nil && strings.Contains(err.Error(), "failed to make dir for artifact") {
    log.Printf("temp dir issue: %v", err) // check permissions/ENOSPC
}

Prevention

When it happens

Trigger: The artifact's name/path (art.Name) contains a directory prefix whose directories cannot be created in the temp build context, or the temp filesystem is unwritable/full.

Common situations: Custom artifact names with nested paths; CI runners with tiny or read-only /tmp; name_template producing paths that conflict with permissions.

Understand the failure class

Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.

Related errors


AI-assisted analysis of goreleaser/goreleaser@f5edd73956 (2026-09-05). Data as JSON: /api/errors/97b0a335839881a2. Report an issue: GitHub.