fix(daemon): respect BD_SOCKET environment variable #1326
+52
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The daemon loop in
runDaemonLoop()was callingrpc.ShortSocketPath()directly instead of checking for theBD_SOCKETenvironment variable first. This caused issues on filesystems where sockets cannot be created in the.beadsdirectory.Problem
When running
bd daemon startwithBD_SOCKETset to a custom path:export BD_SOCKET=/tmp/bd-custom.sock bd daemon startThe daemon would ignore this and still try to create the socket in
.beads/bd.sock, failing with:Specific Setup
This was encountered on macOS with a bind-mounted workspace volume in a devcontainer/devpod setup. The workspace at
/workspaces/evalis mounted from the host filesystem. On this mount:chmod()on the socket returnsEINVALThe daemon creates the socket successfully but then tries to set permissions (0600) on it, which fails on this filesystem.
Solution
Check
BD_SOCKETenvironment variable before falling back to the default path computation, consistent with howgetSocketPath()andgetSocketPathForPID()already work.This allows users to set
BD_SOCKETto 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: truein.beads/config.yaml, which disables the daemon entirely and uses direct database access.Test plan
TestDaemonLoopSocketPathEnvOverrideto verify BD_SOCKET is respectedTestDaemonLoopSocketPathDefaultto verify default behavior unchanged🤖 Generated with Claude Code