ipfs/kubo · error

file Rename error: , file remove error

Error message

file Rename error: %s, file remove error: %s

What it means

While writing the daemon's API address file: the atomic rename of the temp file to 'api' failed AND the cleanup removal of the temp file also failed; both errors are reported so no orphaned temp file is left silently.

Solutions

  1. Remove the leftover '.api.tmp' file in the repo directory
  2. Check filesystem permissions and that the repo is not on a broken mount
  3. Restart the daemon to retry writing the API address
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at repo/fsrepo/fsrepo.go:410 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at repo/fsrepo/fsrepo.go:410

		return err
	}

	if _, err = f.WriteString(addr.String()); err != nil {
		f.Close()
		return err
	}
	if err = f.Close(); err != nil {
		return err
	}

	// Atomically rename the temp file to the correct file name.
	if err = os.Rename(filepath.Join(r.path, "."+apiFile+".tmp"), filepath.Join(r.path,
		apiFile)); err == nil {
		return nil
	}
	// Remove the temp file when rename return error
	if err1 := os.Remove(filepath.Join(r.path, "."+apiFile+".tmp")); err1 != nil {
		return fmt.Errorf("file Rename error: %s, file remove error: %s", err.Error(),
			err1.Error())
	}
	return err
}

// SetGatewayAddr writes the Gateway Addr to the /gateway file.
func (r *FSRepo) SetGatewayAddr(addr net.Addr) error {
	// Create a temp file to write the address, so that we don't leave empty file when the
	// program crashes after creating the file.
	tmpPath := filepath.Join(r.path, "."+gatewayFile+".tmp")
	f, err := os.Create(tmpPath)
	if err != nil {
		return err
	}
	var good bool
	// Silently remove as worst last case with defers.
	defer func() {
		if !good {

View on GitHub (pinned to 329838acdf)