gastownhall/beads · error
writing managed sql-server config: %w
Error message
writing managed sql-server config: %w
What it means
Start() writes the rendered YAML to the managed config file (mode 0600) so the child dolt sql-server can load it via -config. An os.WriteFile failure is wrapped as 'writing managed sql-server config'. Non-explicit ports retry; explicit ports stop and surface lastErr.
Source
Thrown at internal/doltserver/doltserver.go:1412
if !explicitPort {
continue
}
break
}
// filepath.Abs defensively: the child's cwd is doltDir (cmd.Dir
// below), so a relative configPath would resolve against the
// wrong directory (matches the sibling dbproxy/server path,
// which abs's its configPath in NewDoltServer).
absConfigPath, absErr := filepath.Abs(doltServerConfigPath(beadsDir))
if absErr != nil {
lastErr = fmt.Errorf("resolving managed sql-server config path: %w", absErr)
if !explicitPort {
continue
}
break
}
if werr := os.WriteFile(absConfigPath, cfgBody, 0600); werr != nil {
lastErr = fmt.Errorf("writing managed sql-server config: %w", werr)
if !explicitPort {
continue
}
break
}
cmdArgs = buildDoltServerArgsWithConfig(absConfigPath, debug, profDir)
} else {
cmdArgs = buildDoltServerArgs(cfg.Host, actualPort, debug, profDir)
}
cmd := exec.Command(doltBin, cmdArgs...) //nolint:gosec // doltBin is resolved from PATH, not user input
cmd.Dir = doltDir
cmd.Stdout = logFile
cmd.Stderr = logFile
cmd.Stdin = nil
cmd.SysProcAttr = procAttrDetached()
cmd.Env = ServerSpawnEnv()
View on GitHub (pinned to 71377f2769)
Solutions
- Check the beads dir is writable by the current user (ls -ld; chown/chmod if needed).
- Remove any directory/file collision at the config path (a directory named like the config file).
- Free disk space / check quota (df -h, quota).
- Confirm no external process (backup/sync tool) is deleting or replacing the beads dir during startup.
Example fix
// before ls -ld ~/.beads # dr-xr-xr-x, read-only // after chmod u+w ~/.beads && bd start
Defensive patterns
Strategy: validation
Validate before calling
const cfgPath = path.join(dataDir, 'dolt-server.yaml');
const st = await fs.stat(dataDir).catch(() => null);
if (!st || !st.isDirectory()) throw new Error('beads dir missing');
await fs.access(dataDir, fs.constants.W_OK);
await fs.access(path.dirname(cfgPath), fs.constants.W_OK); Type guard
null
Try / catch
try {
await bdStart();
} catch (e) {
if (/writing managed sql-server config/.test(e.message)) {
// chown/chmod the beads dir, check disk space, then retry
}
throw e;
} Prevention
- Keep the beads dir writable for the service user.
- Watch disk quotas and free space.
- Exclude the beads dir from tools that flip it read-only.
- Recreate dir permissions after user/uid changes.
When it happens
Trigger: os.WriteFile(absConfigPath, cfgBody, 0600) fails: parent directory missing/unwritable, disk full, or path points at a directory.
Common situations: Read-only filesystem after mount remount; quota exceeded; beads dir recreated by another process mid-start; permission drift after running bd as different users.
Related errors
- resolving .doltcfg directory: %w
- resolving managed sql-server config path: %w
- multiple .doltcfg directories detected
- write metadata.json: %w
- %s: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/1530832ff20c8bcc.
Report an issue: GitHub.