{"record":{"id":"38476add15d45b3c","repo":"ipfs/kubo","slug":"copying-binary-to-stash-w","errorCode":null,"errorMessage":"copying binary to stash: %w","messagePattern":"copying binary to stash: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/update.go","lineNumber":620,"sourceCode":"\n\tsrc, err := os.Open(binPath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"opening current binary: %w\", err)\n\t}\n\tdefer src.Close()\n\n\tdst, err := os.OpenFile(stashPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o755)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"creating stash file: %w\", err)\n\t}\n\tdefer func() {\n\t\tif cerr := dst.Close(); cerr != nil && err == nil {\n\t\t\terr = fmt.Errorf(\"writing stash file: %w\", cerr)\n\t\t}\n\t}()\n\n\tif _, err = io.Copy(dst, src); err != nil {\n\t\treturn \"\", fmt.Errorf(\"copying binary to stash: %w\", err)\n\t}\n\tif err = dst.Sync(); err != nil {\n\t\treturn \"\", fmt.Errorf(\"syncing stash file: %w\", err)\n\t}\n\n\treturn stashPath, nil\n}\n\n// stashEntry describes a single backed-up Kubo binary in the stash directory.\ntype stashEntry struct {\n\tpath   string\n\tname   string\n\tver    string\n\tparsed *goversion.Version\n\tsize   int64\n}\n\n// listStashes returns every stashed binary in dir, newest first. Files that","sourceCodeStart":602,"sourceCodeEnd":638,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/update.go#L602-L638","documentation":"`stashBinary` backs up the currently installed kubo binary into `<IPFS_PATH>/stash/` before an update. This error wraps any failure of `io.Copy(dst, src)` while copying the binary bytes into the stash file, so the backup is incomplete and the update aborts rather than leaving the operator without a rollback binary.","triggerScenarios":"An I/O error while streaming the current binary into the stash file: disk full during the copy, source file read error (permissions, device error), or an interrupted write to the destination file.","commonSituations":"Running `ipfs update` when the disk containing $IPFS_PATH is full; $IPFS_PATH on a network/USB mount that drops mid-copy; the ipfs binary on a read-only or removable medium whose read fails partway.","solutions":["Check free space on the filesystem holding IPFS_PATH: `df -h \"$IPFS_PATH\"` and free space if full.","Confirm the current binary is readable: `cat \"$(which ipfs)\" > /dev/null` to surface read errors.","Delete the partial stash file (e.g. `$IPFS_PATH/stash/ipfs-<ver>`) and retry `ipfs update`.","If $IPFS_PATH is on flaky storage, move it to a reliable local disk or set IPFS_PATH to a healthy path for the update."],"exampleFix":"// diagnosis\nls -lh \"$IPFS_PATH/stash/\"   # partial/zero-length stash file\ndf -h \"$IPFS_PATH\"           # 100% used\n# after freeing space, remove the bad stash entry and retry\nrm \"$IPFS_PATH/stash/ipfs-0.30.0\"\nipfs update","handlingStrategy":"try-catch","validationCode":"// before update: ensure the source binary is readable and space exists\nstat, err := os.Stat(binPath)\nif err != nil { /* cannot read current binary */ }\nusage, _ := diskUsage(filepath.Dir(stashPath))\nif usage.Free < stat.Size()+overhead { /* abort early: not enough space to stash */ }","typeGuard":null,"tryCatchPattern":"stashPath, err := stashBinary(binPath, ver)\nif err != nil {\n\tvar perr *os.PathError\n\tif errors.As(err, &perr) {\n\t\tlog.Printf(\"stash copy failed on %s: %v (check disk space/permissions)\", perr.Path, perr.Err)\n\t}\n\treturn fmt.Errorf(\"backup aborted, current binary untouched: %w\", err)\n}","preventionTips":["Keep several GB free on the filesystem holding IPFS_PATH.","Do not put IPFS_PATH on removable or network mounts.","Run updates as the owning user, not via sudo, so permissions match.","If a partial stash file appears, delete it before retrying."],"tags":["io","filesystem","disk","update"],"backgroundTag":"disk-full-io-error","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}