gastownhall/beads · error
failed to get hostname: %w
Error message
failed to get hostname: %w
What it means
GetCloneIDForPath builds a clone identifier from hostname + normalized main repo path. Its first step is os.Hostname(); if the OS cannot report a hostname, the failure is wrapped as "failed to get hostname". Without a hostname the clone ID would not be unique per machine, so bd refuses to guess.
Source
Thrown at internal/beads/fingerprint.go:155
}
return filepath.ToSlash(evalPath), nil
}
// GetCloneID generates a unique ID for this specific clone (not shared with other clones)
func GetCloneID() (string, error) {
return GetCloneIDForPath("")
}
// GetCloneIDForPath generates a unique ID for the specific clone rooted at or
// containing repoPath. An empty repoPath uses the current cwd.
//
// GH#2867: Uses the main repo root (not worktree root) so that all worktrees
// sharing a database produce the same clone ID.
func GetCloneIDForPath(repoPath string) (string, error) {
hostname, err := os.Hostname()
if err != nil {
return "", fmt.Errorf("failed to get hostname: %w", err)
}
repoRoot, err := mainRepoRootForPath(repoPath)
if err != nil {
return "", fmt.Errorf("not a git repository: %w", err)
}
normalizedPath := normalizedRepoPath(repoRoot)
hash := sha256.Sum256([]byte(hostname + ":" + normalizedPath))
return hex.EncodeToString(hash[:8]), nil
}
func runGitInRepo(repoPath string, args ...string) ([]byte, error) {
cmd := exec.Command("git", args...)
if repoPath != "" {
cmd.Dir = repoPath
}
return cmd.Output()View on GitHub (pinned to 71377f2769)
Solutions
- Set a hostname for the environment (e.g. `hostnamectl set-hostname myhost` or Docker `--hostname myhost`)
- Fix /etc/hostname (or the platform equivalent) and restart the process
- Check sandbox/seccomp policies that block uname/gethostname syscalls
- If it is transient, retry — os.Hostname failures are rarely retriable but a container restart usually resolves it
Example fix
// docker run before $ docker run acme/bd // after $ docker run --hostname devbox acme/bd
Defensive patterns
Strategy: retry
Validate before calling
if _, err := os.Hostname(); err != nil {
// fix environment hostname before using clone-ID APIs
} Try / catch
cloneID, err := beads.GetCloneIDForPath(path)
if err != nil && strings.Contains(err.Error(), "failed to get hostname") {
return fmt.Errorf("set a hostname for this environment: %w", err)
} Prevention
- Always configure a hostname in containers (--hostname) and chroots
- Keep /etc/hostname valid on minimal systems
- Check sandbox policies don't block gethostname/uname
- Retry after container restart if the failure was transient
When it happens
Trigger: Calling GetCloneID/GetCloneIDForPath on a system where os.Hostname() returns an error — severely restricted environments, containers with no set hostname, or exotic sandboxes where the utsname is unavailable.
Common situations: Minimal containers/chroots without a configured hostname; hardened sandboxes blocking uname; embedded systems with unset machine names; test environments faking syscalls.
Related errors
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/b9dfd946b52b6738.
Report an issue: GitHub.