ipfs/kubo · error

writing temp file: %w

Error message

writing temp file: %w

What it means

`writeBinaryToTempFile` wraps a failure of `f.Write(data)` with this message while writing the downloaded kubo binary bytes into the temp executable. The write could not complete (fully or at all), so the staged binary is incomplete; the deferred cleanup removes the partial file.

Source

Thrown at core/commands/update.go:735

// writeBinaryToTempFile writes data to a uniquely named executable file
// in the system temp directory and returns its path.
func writeBinaryToTempFile(data []byte, ver string) (path string, err error) {
	pattern := migrations.ExeName(fmt.Sprintf("ipfs-%s-*", ver))
	f, err := os.CreateTemp("", pattern)
	if err != nil {
		return "", fmt.Errorf("creating temp file: %w", err)
	}
	defer func() {
		if cerr := f.Close(); cerr != nil && err == nil {
			err = fmt.Errorf("closing temp file: %w", cerr)
		}
		if err != nil {
			os.Remove(f.Name())
		}
	}()

	if _, err = f.Write(data); err != nil {
		return "", fmt.Errorf("writing temp file: %w", err)
	}
	if err = f.Sync(); err != nil {
		return "", fmt.Errorf("syncing temp file: %w", err)
	}
	if err = f.Chmod(0o755); err != nil {
		return "", fmt.Errorf("chmod temp file: %w", err)
	}
	return f.Name(), nil
}

// extractBinaryFromArchive extracts the kubo/ipfs binary from a tar.gz or zip archive.
func extractBinaryFromArchive(data []byte) ([]byte, error) {
	binName := migrations.ExeName("ipfs")

	// Try tar.gz first (Unix releases), then zip (Windows releases).
	result, tarErr := extractFromTarGz(data, binName)
	if tarErr == nil {
		return result, nil

View on GitHub (pinned to 329838acdf)

Solutions

  1. Check free space and quota: `df -h "$TMPDIR"` and `quota -s`; free space or point TMPDIR at a larger filesystem.
  2. Rerun the update — the partial temp file is removed automatically, so a retry is safe.
  3. Check `dmesg` for block-device errors if space is not the issue.
  4. For containers, raise the ephemeral-storage/tmpfs size or bind-mount a larger directory as TMPDIR.

Example fix

// diagnosis
ls -l "$TMPDIR"/ipfs-*          # partial file (removed automatically)
df -h "$TMPDIR"                  # 0 available

# after freeing space or repointing TMPDIR
export TMPDIR=/var/tmp
ipfs update install v0.30.0
Defensive patterns

Strategy: validation

Validate before calling

// ensure room for the new binary before staging
const minFree = 200 << 20
if free, err := freeSpace(os.TempDir()); err != nil || free < minFree {
	// abort early: temp filesystem cannot hold the binary
}
// and ensure quota headroom
if quotaExceeded(os.Getuid()) { /* clean up or switch TMPDIR */ }

Try / catch

if err != nil {
	var perr *os.PathError
	if errors.As(err, &perr) && errors.Is(perr.Err, syscall.ENOSPC) {
		return fmt.Errorf("temp filesystem full; free space on %s and retry", os.TempDir())
	}
	return err
}

Prevention

When it happens

Trigger: `ipfs update install` when the temp filesystem fills during the write, the storage device reports an I/O error, or the write is interrupted (fs unmounted, quota exceeded on TMPDIR).

Common situations: Updating a large kubo binary onto a nearly-full /tmp or small tmpfs; per-user disk quotas hit during the write; failing disk sectors; container ephemeral storage limits.

Related errors


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/9cc786f062ce2c34. Report an issue: GitHub.