-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Summary
bd worktree create generates redirect paths that don't work because the write and read sides use different base directories for relative path resolution.
Root Cause
In cmd/bd/worktree_cmd.go, the code comments say paths should be relative to worktree root:
// Compute relative path from worktree root (not .beads dir) because
// FollowRedirect resolves paths relative to the parent of .beads
worktreeRoot := filepath.Dir(worktreeBeadsDir)
relPath, err := filepath.Rel(worktreeRoot, absMainBeadsDir)But getRedirectTarget() in the same file resolves from .beads/ directory:
func getRedirectTarget(worktreePath string) string {
// ...
if !filepath.IsAbs(target) {
beadsDir := filepath.Join(worktreePath, ".beads")
target = filepath.Join(beadsDir, target) // ← resolves from .beads!
}
// ...
}Steps to Reproduce
cd /home/user/projects/myrepo
bd init
bd worktree create ../myrepo.worktrees/feature-1 --branch feature-1
# Check what bd wrote
cat ../myrepo.worktrees/feature-1/.beads/redirect
# Output: ../../../myrepo/.beads
# Test if it works
cd ../myrepo.worktrees/feature-1
bd list
# Warning: redirect target does not exist or is not a directory: /home/user/myrepo/.beadsAnalysis
From /home/user/projects/myrepo.worktrees/feature-1/.beads/:
../../../myrepo/.beadsresolves to/home/user/projects/myrepo/.beads✓
But getRedirectTarget() joins with .beads dir first:
filepath.Join(".beads", "../../../myrepo/.beads")→ resolves from.beads/- Goes only 2 levels up from worktree root →
/home/user/myrepo/.beads✗
Workaround
Manually fix the redirect to be relative to .beads/ directory (add one more ../):
echo "../../../../myrepo/.beads" > .beads/redirectOr use path relative to worktree root (what the read side actually expects despite the comment):
echo "../../myrepo/.beads" > .beads/redirectSuggested Fix
Either:
- Fix write side to compute path relative to
.beads/directory (matching read side) - Fix read side to resolve from worktree root (matching comment and write side)
Option 1 seems simpler - just remove the filepath.Dir() call:
// relPath, err := filepath.Rel(worktreeRoot, absMainBeadsDir) // current
relPath, err := filepath.Rel(worktreeBeadsDir, absMainBeadsDir) // fixedEnvironment
- bd version: 0.49.0
- Linux (also reproducible on macOS per bd worktree create generates incorrect relative path for redirect #1098)
Related
- bd worktree create generates incorrect relative path for redirect #1098 (closed, incomplete fix)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels