ipfs/kubo · error
failed to get temp dir: %s
Error message
failed to get temp dir: %s
What it means
initTempNode fails with this when os.MkdirTemp("", "ipfs-temp") cannot create a temporary directory. The ephemeral node used to fetch migration artifacts cannot even get its repo directory, so the wrapped os error is reported.
Source
Thrown at repo/fsrepo/migrations/ipfsfetcher/ipfsfetcher.go:187
f.fetched = append(f.fetched, fetchedPath)
}
func initTempNode(ctx context.Context, bootstrap []string, peers []peer.AddrInfo) (string, error) {
identity, err := config.CreateIdentity(io.Discard, []options.KeyGenerateOption{
options.Key.Type(options.Ed25519Key),
})
if err != nil {
return "", err
}
cfg, err := config.InitWithIdentity(identity)
if err != nil {
return "", err
}
// create temporary ipfs directory
dir, err := os.MkdirTemp("", "ipfs-temp")
if err != nil {
return "", fmt.Errorf("failed to get temp dir: %s", err)
}
// configure the temporary node
cfg.Routing.Type = config.NewOptionalString("dhtclient")
// Disable listening for inbound connections
cfg.Addresses.Gateway = []string{}
cfg.Addresses.API = []string{}
cfg.Addresses.Swarm = []string{tempNodeTCPAddr}
if len(bootstrap) != 0 {
cfg.Bootstrap = bootstrap
}
if len(peers) != 0 {
cfg.Peering.Peers = peers
}
View on GitHub (pinned to 329838acdf)
Solutions
- Set TMPDIR to a writable path and retry
- Check free disk space and permissions on the temp directory
- Run with a filesystem-writable environment (e.g. writable emptyDir in k8s)
Example fix
// before export TMPDIR=/nonexistent ipfs migrate // after export TMPDIR=$(mktemp -d) ipfs migrate
Defensive patterns
Strategy: validation
Validate before calling
tmp := os.TempDir()
if st, err := os.Stat(tmp); err != nil || !st.IsDir() {
return fmt.Errorf("TMPDIR %q is not a usable directory", tmp)
}
if err := os.MkdirTemp(tmp, "ipfs-temp-probe"); err != nil { return err } // probe writability Try / catch
dir, err := initTempNode(ctx)
if err != nil && strings.HasPrefix(err.Error(), "failed to get temp dir") {
os.Setenv("TMPDIR", "/var/tmp") // or another writable dir, then retry
} Prevention
- Ensure TMPDIR is writable in containers/CI
- Keep free disk space on the temp filesystem
- Avoid read-only /tmp for daemon/migration workloads
When it happens
Trigger: TMPDIR pointing to a non-writable or nonexistent location; disk full; restrictive umask/permissions; running in a hardened container with read-only /tmp or no temp mounts.
Common situations: Docker/Kubernetes sandboxes with read-only /tmp; systemd services with PrivateTmp and misconfigured paths; CI runners with TMPDIR set to a cleaned directory.
Related errors
- abort failed: close: %w, remove: %v
- %s path (%q) does not exist: %w
- source field %s does not exist
- %q is not a file
- failed to initialize ephemeral node: %s
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/6f3a4df225513f6e.
Report an issue: GitHub.