hyperledger/fabric · error
error while creating the dir: %s, ensure peer has write acce
Error message
error while creating the dir: %s, ensure peer has write access to configured ledger.snapshots.rootDir directory
What it means
initSnapshotDir wraps the os.MkdirAll error when creating either the in-progress or completed snapshots directory under the configured root fails. Fabric ensures both directories exist (mode 0755) at provider startup; failure to create them halts peer startup with this message advising a write-access check on ledger.snapshots.rootDir.
Source
Thrown at core/ledger/kvledger/kv_ledger_provider.go:261
func (p *Provider) initLedgerStatistics() {
p.stats = newStats(p.initializer.MetricsProvider)
}
func (p *Provider) initSnapshotDir() error {
snapshotsRootDir := p.initializer.Config.SnapshotsConfig.RootDir
if !filepath.IsAbs(snapshotsRootDir) {
return errors.Errorf("invalid path: %s. The path for the snapshot dir is expected to be an absolute path", snapshotsRootDir)
}
inProgressSnapshotsPath := SnapshotsTempDirPath(snapshotsRootDir)
completedSnapshotsPath := CompletedSnapshotsPath(snapshotsRootDir)
if err := os.RemoveAll(inProgressSnapshotsPath); err != nil {
return errors.Wrapf(err, "error while deleting the dir: %s", inProgressSnapshotsPath)
}
if err := os.MkdirAll(inProgressSnapshotsPath, 0o755); err != nil {
return errors.Wrapf(err, "error while creating the dir: %s, ensure peer has write access to configured ledger.snapshots.rootDir directory", inProgressSnapshotsPath)
}
if err := os.MkdirAll(completedSnapshotsPath, 0o755); err != nil {
return errors.Wrapf(err, "error while creating the dir: %s, ensure peer has write access to configured ledger.snapshots.rootDir directory", completedSnapshotsPath)
}
return fileutil.SyncDir(snapshotsRootDir)
}
// CreateFromGenesisBlock implements the corresponding method from interface ledger.PeerLedgerProvider
// This function creates a new ledger and commits the genesis block. If a failure happens during this
// process, the partially created ledger is deleted
func (p *Provider) CreateFromGenesisBlock(genesisBlock *common.Block) (ledger.PeerLedger, error) {
ledgerID, err := protoutil.GetChannelIDFromBlock(genesisBlock)
if err != nil {
return nil, err
}
if err = p.idStore.createLedgerID(
ledgerID,
&msgs.LedgerMetadata{View on GitHub (pinned to 2736b63f8f)
Solutions
- Confirm the peer's OS user has write access to ledger.snapshots.rootDir (chown/chmod)
- Ensure the rootDir path is a directory, not a file; remove/rename any conflicting file
- Remount the volume read-write if mounted read-only
- Create the directory manually with mode 0755 and restart the peer
Example fix
// before: error while creating the dir: /var/hyperledger/production/snapshots/completedSnapshots: mkdir: read-only file system
// after:
# mkdir -p -m 0755 /var/hyperledger/production/snapshots/{inProgressSnapshots,completedSnapshots}
# chown -R fabric:fabric /var/hyperledger/production/snapshots
# peer node start Defensive patterns
Strategy: validation
Validate before calling
rootDir := viper.GetString("ledger.snapshots.rootDir")
if info, err := os.Stat(rootDir); err != nil {
return fmt.Errorf("snapshots rootDir %q missing", rootDir)
} else if !info.IsDir() {
return fmt.Errorf("snapshots rootDir %q is not a directory", rootDir)
} else if !isWritable(rootDir) {
return fmt.Errorf("no write access to snapshots rootDir %q", rootDir)
} Prevention
- Pre-create inProgressSnapshots and completedSnapshots with mode 0755
- Verify volume is writable by the peer's runtime user before deployment
- Ensure ledger.snapshots.rootDir points to a directory, not a file
When it happens
Trigger: Peer startup (NewProvider -> initSnapshotDir) when os.MkdirAll fails for SnapshotsTempDirPath or CompletedSnapshotsPath: parent dir missing and uncreatable, no write permission, read-only mount, or path is actually a file.
Common situations: Snapshots rootDir pointing to a read-only volume, path exists as a regular file, peer running as non-root without rights to the configured directory, or typo'd path under a non-writable parent.
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 deleting the dir: %s
- error while reading bootstrappingSnapshotInfo file
- failed to read bootstrappingSnapshotInfo file under blocksto
- Error creating block storage root dir [%s]: %s
- failed reading directory %s
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/c8c77c24bc4bb845.
Report an issue: GitHub.