gastownhall/beads · error

resolving managed sql-server config path: %w

Error message

resolving managed sql-server config path: %w

What it means

After rendering the config body, Start() converts the managed config file path (doltServerConfigPath(beadsDir)) to an absolute path with filepath.Abs, because the child process's cwd is doltDir and a relative path would resolve against the wrong directory. A filepath.Abs failure (current working directory unresolvable, e.g. deleted cwd) is wrapped as 'resolving managed sql-server config path'.

Source

Thrown at internal/doltserver/doltserver.go:1405

			}

			var cmdArgs []string
			if useArchiveLevelConfig {
				cfgBody, cfgErr := buildDoltServerYAMLConfig(cfg.Host, actualPort, debug, cfgDir)
				if cfgErr != nil {
					lastErr = fmt.Errorf("rendering managed sql-server config: %w", cfgErr)
					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

View on GitHub (pinned to 71377f2769)

Solutions

  1. Restart bd from an existing working directory (cd / && bd ...).
  2. If bd runs as a daemon, set its WorkingDirectory in the service unit to an existing path.
  3. Ensure nothing deletes the directory bd was launched from while it runs.
  4. Upgrade beads if a released fix caches the absolute path earlier in startup.

Example fix

// before: launched from a dir deleted later
rm -rf /tmp/scratch   # bd cwd was /tmp/scratch
// after
cd / && bd start
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure the process cwd exists before starting
class ExistsSyncGuard { static ok(p){ return require('fs').existsSync(p); } }
if (!ExistsSyncGuard.ok(process.cwd())) throw new Error('cwd deleted; restart bd from an existing directory');

Type guard

function cwdExists() { try { process.cwd(); return true; } catch { return false; } }

Try / catch

try {
  await bdStart();
} catch (e) {
  if (/resolving managed sql-server config path/.test(e.message)) {
    // restart bd from an existing working directory
  }
  throw e;
}

Prevention

When it happens

Trigger: useArchiveLevelConfig true and filepath.Abs fails — practically only when the process's working directory has been removed or its chain cannot be evaluated.

Common situations: The bd process was started from a directory that was later deleted; containers or daemons launched with a nonexistent cwd.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/1feabdb05eea2a08. Report an issue: GitHub.