Skip to content

Conversation

@jdelfino
Copy link

@jdelfino jdelfino commented Jan 26, 2026

Summary

The daemon loop in runDaemonLoop() was calling rpc.ShortSocketPath() directly instead of checking for the BD_SOCKET environment variable first. This caused issues on filesystems where sockets cannot be created in the .beads directory.

Problem

When running bd daemon start with BD_SOCKET set to a custom path:

export BD_SOCKET=/tmp/bd-custom.sock
bd daemon start

The daemon would ignore this and still try to create the socket in .beads/bd.sock, failing with:

failed to set socket permissions: chmod /workspaces/eval/.beads/bd.sock: invalid argument

Specific Setup

This was encountered on macOS with a bind-mounted workspace volume in a devcontainer/devpod setup. The workspace at /workspaces/eval is mounted from the host filesystem. On this mount:

  • Regular files work fine
  • Unix sockets can be created but chmod() on the socket returns EINVAL
  • This appears to be a limitation of how macOS handles socket permissions on certain mount types

The daemon creates the socket successfully but then tries to set permissions (0600) on it, which fails on this filesystem.

Solution

Check BD_SOCKET environment variable before falling back to the default path computation, consistent with how getSocketPath() and getSocketPathForPID() already work.

This allows users to set BD_SOCKET to a path on a local filesystem (like /tmp) where socket operations work normally.

Workaround

Until this fix is merged, users can work around the issue by setting no-daemon: true in .beads/config.yaml, which disables the daemon entirely and uses direct database access.

Test plan

  • Added TestDaemonLoopSocketPathEnvOverride to verify BD_SOCKET is respected
  • Added TestDaemonLoopSocketPathDefault to verify default behavior unchanged
  • All existing socket tests pass
  • Manually verified fix works on macOS bind-mounted filesystem

🤖 Generated with Claude Code

The daemon loop in runDaemonLoop() was calling rpc.ShortSocketPath()
directly instead of checking for the BD_SOCKET environment variable
first. This caused issues on filesystems where sockets cannot be
created in the .beads directory (e.g., some mounted filesystems
that don't support Unix socket permissions).

The fix checks BD_SOCKET before falling back to the default path
computation, consistent with how getSocketPath() and
getSocketPathForPID() already work.

Added tests to verify the daemon loop respects BD_SOCKET.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jdelfino jdelfino changed the title Fix daemon to respect BD_SOCKET environment variable fix(daemon): respect BD_SOCKET environment variable Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant