hyperledger/fabric · error
error while creating temp dir [%s]
Error message
error while creating temp dir [%s]
What it means
generateSnapshot creates a temporary directory under <snapshotsRootDir>/temp to stage snapshot files before finalizing. This error wraps an os.MkdirTemp failure, meaning the OS refused to create the staging directory (permissions, missing parent, disk full, etc.).
Source
Thrown at core/ledger/kvledger/snapshot.go:105
snapshotAdditionalMetadata: additionalMetadata,
}, nil
}
// generateSnapshot generates a snapshot. This function should be invoked when commit on the kvledger are paused
// after committing the last block fully and further the commits should not be resumed till this function finishes
func (l *kvLedger) generateSnapshot() error {
snapshotsRootDir := l.config.SnapshotsConfig.RootDir
bcInfo, err := l.GetBlockchainInfo()
if err != nil {
return err
}
lastBlockNum := bcInfo.Height - 1
snapshotTempDir, err := os.MkdirTemp(
SnapshotsTempDirPath(snapshotsRootDir),
fmt.Sprintf("%s-%d-", l.ledgerID, lastBlockNum),
)
if err != nil {
return errors.Wrapf(err, "error while creating temp dir [%s]", snapshotTempDir)
}
defer os.RemoveAll(snapshotTempDir)
newHashFunc := func() (hash.Hash, error) {
return l.hashProvider.GetHash(snapshotHashOpts)
}
txIDsExportSummary, err := l.blockStore.ExportTxIds(snapshotTempDir, newHashFunc)
if err != nil {
return err
}
logger.Debugw("Exported TxIDs from blockstore", "channelID", l.ledgerID)
configsHistoryExportSummary, err := l.configHistoryRetriever.ExportConfigHistory(snapshotTempDir, newHashFunc)
if err != nil {
return err
}
logger.Debugw("Exported collection config history", "channelID", l.ledgerID)View on GitHub (pinned to 2736b63f8f)
Solutions
- Check snapshots.rootDir exists and is writable by the peer process user (ls -ld, touch a file inside it)
- Fix volume mount permissions/ownership in the container or host
- Free disk space / inodes on the snapshots volume
- Correct the core.yaml snapshots.rootDir path if it points to an invalid location
Example fix
// before snapshots: rootDir: /var/snapshots # read-only mount // after snapshots: rootDir: /var/hyperledger/production/snapshots # writable volume; chown peer:peer
Defensive patterns
Strategy: try-catch
Validate before calling
const dir = "/var/hyperledger/production/snapshots"
if fi, err := os.Stat(dir); err != nil || !fi.IsDir() { return errors.New("snapshots rootDir missing or not a directory") }
probe := filepath.Join(dir, ".write-test")
if err := os.WriteFile(probe, nil, 0o600); err != nil { return errors.New("snapshots rootDir not writable") }
os.Remove(probe) Try / catch
err := ledger.GenerateSnapshot()
var pe *fs.PathError
if err != nil && errors.As(err, &pe) {
log.Errorf("snapshot temp dir creation failed (%s): check permissions/space on %s", pe.Op, pe.Path)
} Prevention
- Pre-create the snapshots rootDir with correct ownership before starting the peer
- Monitor disk space and inodes on the snapshots volume
- Run the peer as a user with write access to mounted volumes
- Validate core.yaml snapshots.rootDir in deployment checks
When it happens
Trigger: Calling ledger.GenerateSnapshot() when the snapshots root's temp directory cannot be created: wrong permissions, root dir deleted while node running, invalid path, or no inodes/space.
Common situations: snapshots.rootDir misconfigured in core.yaml to a read-only or non-existent volume; container running as non-root without write access to mounted volume; disk-full conditions on Kubernetes PVCs.
Understand the failure class
Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.
Related errors
- error while reading bootstrappingSnapshotInfo file
- failed to read bootstrappingSnapshotInfo file under blocksto
- error while deleting the dir: %s
- error while creating the dir: %s, ensure peer has write acce
- error while creating final dir for snapshot:%s
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/fd75a7717f6afd7e.
Report an issue: GitHub.