gastownhall/beads · error
server: NewDoltServer: failed to determine absolute path of
Error message
server: NewDoltServer: failed to determine absolute path of doltBinExec
What it means
NewDoltServer resolves doltBinExec to an absolute path with filepath.Abs so the spawned `dolt sql-server` child process gets a stable, cwd-independent binary path. filepath.Abs only fails when the process's current working directory cannot be determined (deleted cwd or getwd failure) and the input path is relative. The library discards the underlying error and returns this fixed message.
Source
Thrown at internal/storage/dbproxy/server/doltserver.go:75
cancel context.CancelFunc
pid int
}
var _ DatabaseServer = (*DoltServer)(nil)
func NewDoltServer(doltBinExec, rootDir, configPath, logFilePath string, keepAlivePeriod time.Duration, database string) (*DoltServer, error) {
if doltBinExec == "" {
return nil, errors.New("server: NewDoltServer: doltBinExec is required")
}
if rootDir == "" {
return nil, errors.New("server: NewDoltServer: rootDir is required")
}
if configPath == "" {
return nil, errors.New("server: NewDoltServer: configPath is required")
}
absDoltBinExec, err := filepath.Abs(doltBinExec)
if err != nil {
return nil, errors.New("server: NewDoltServer: failed to determine absolute path of doltBinExec")
}
absRootDir, err := filepath.Abs(rootDir)
if err != nil {
return nil, errors.New("server: NewDoltServer: failed to determine absolute path of rootDir")
}
absConfigPath, err := filepath.Abs(configPath)
if err != nil {
return nil, errors.New("server: NewDoltServer: failed to determine absolute path of configPath")
}
cfg, err := servercfg.YamlConfigFromFile(filesys.LocalFS, configPath)
if err != nil {
return nil, fmt.Errorf("server: NewDoltServer: parse config %q: %w", configPath, err)
}
var logFile *os.File
if logFilePath != "" {
absLogFilePath, err := filepath.Abs(logFilePath)
if err != nil {
return nil, errors.New("server: NewDoltServer: failed to determine absolute path of logFilePath")View on GitHub (pinned to 71377f2769)
Solutions
- Pass an absolute doltBinExec (filepath.Abs it yourself at startup, when the cwd is still valid, and cache the result)
- Check the process cwd: ls -l /proc/$(pgrep -f bd)/cwd — if it is deleted, restart the process from a valid directory
- Restart the application from a directory that exists
Example fix
// before
srv, err := server.NewDoltServer("./bin/dolt", rootDir, cfgPath, logPath, 0, db)
// after
absBin, err := filepath.Abs("./bin/dolt") // do this early, while cwd is valid
if err != nil { return err }
srv, err := server.NewDoltServer(absBin, rootDir, cfgPath, logPath, 0, db) Defensive patterns
Strategy: validation
Validate before calling
bin, err := filepath.Abs(doltBinExec)
if err != nil { return fmt.Errorf("cannot resolve dolt binary path (cwd invalid?): %w", err) }
if _, err := os.Stat(bin); err != nil { return fmt.Errorf("dolt binary not found at %s: %w", bin, err) } Prevention
- Resolve all paths (binary, rootDir, config, log) to absolute at process startup, before any chdir
- Cache os.Getwd() early; if it fails at startup, fail fast with a clear message
- Never rely on relative paths in long-running daemons or containers
- Alert on cwd deletion in supervised services (systemd WorkingDirectory checks)
When it happens
Trigger: Calling NewDoltServer with a relative doltBinExec (e.g. "./bin/dolt") while the process cwd is invalid: the working directory was deleted after the process started, or the OS getwd call failed. An absolute doltBinExec would never hit this branch.
Common situations: Long-running daemons whose working directory was removed or replaced (e.g. tmp cleanup deleted the cwd); launching bd from a shell sitting in a since-deleted directory; container environments where the entrypoint chdirs into an erased path.
Related errors
- server: NewDoltServer: failed to determine absolute path of
- server: NewDoltServer: failed to determine absolute path of
- server: NewDoltServer: failed to determine absolute path of
- invalid workspace path: %w
- writing port file: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/6e0db2972ce9e817.
Report an issue: GitHub.