From 2514507a49a0ad6547b15c1545f99ffb8236170e Mon Sep 17 00:00:00 2001 From: Roland Tritsch Date: Thu, 22 Jan 2026 03:50:38 +0000 Subject: [PATCH] Fix GT_ROOT export for beads formula search compatibility (#718) Problem: - Gas Town sets GT_TOWN_ROOT environment variable - Beads searches for formulas using GT_ROOT environment variable - This naming inconsistency prevents beads from finding town-level formulas - Result: `bd mol seed --patrol` fails in rigs, causing false doctor warnings Solution: Export both GT_TOWN_ROOT and GT_ROOT from `gt rig detect` command: - Modified stdout output to export both variables (lines 66, 70) - Updated cache storage format (lines 134, 136, 138) - Updated unset statement for both variables (line 110) - Updated command documentation (lines 33, 37) Both variables point to the same town root path. This maintains backward compatibility with Gas Town (GT_TOWN_ROOT) while enabling beads formula search (GT_ROOT). Testing: - `gt rig detect .` now outputs both GT_TOWN_ROOT and GT_ROOT - `bd mol seed --patrol` works correctly when GT_ROOT is set - Formula search paths work as expected: town/.beads/formulas/ accessible Related: - Complements bd mol seed --patrol implementation (beads PR #1149) - Complements patrol formula doctor check fix (gastown PR #715) Co-authored-by: Roland Tritsch Co-authored-by: Claude Sonnet 4.5 --- internal/cmd/rig_detect.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/internal/cmd/rig_detect.go b/internal/cmd/rig_detect.go index 76089a17..ec76fb55 100644 --- a/internal/cmd/rig_detect.go +++ b/internal/cmd/rig_detect.go @@ -30,10 +30,11 @@ for fast lookups by the shell hook. Output format (to stdout): export GT_TOWN_ROOT=/path/to/town + export GT_ROOT=/path/to/town export GT_RIG=rigname Or if not in a rig: - unset GT_TOWN_ROOT GT_RIG`, + unset GT_TOWN_ROOT GT_ROOT GT_RIG`, Args: cobra.MaximumNArgs(1), RunE: runRigDetect, } @@ -63,9 +64,11 @@ func runRigDetect(cmd *cobra.Command, args []string) error { if rigName != "" { fmt.Printf("export GT_TOWN_ROOT=%q\n", townRoot) + fmt.Printf("export GT_ROOT=%q\n", townRoot) fmt.Printf("export GT_RIG=%q\n", rigName) } else { fmt.Printf("export GT_TOWN_ROOT=%q\n", townRoot) + fmt.Printf("export GT_ROOT=%q\n", townRoot) fmt.Println("unset GT_RIG") } @@ -105,7 +108,7 @@ func detectRigFromPath(townRoot, absPath string) string { } func outputNotInRig() error { - fmt.Println("unset GT_TOWN_ROOT GT_RIG") + fmt.Println("unset GT_TOWN_ROOT GT_ROOT GT_RIG") return nil } @@ -129,11 +132,11 @@ func updateRigCache(repoRoot, townRoot, rigName string) error { var value string if rigName != "" { - value = fmt.Sprintf("export GT_TOWN_ROOT=%q; export GT_RIG=%q", townRoot, rigName) + value = fmt.Sprintf("export GT_TOWN_ROOT=%q; export GT_ROOT=%q; export GT_RIG=%q", townRoot, townRoot, rigName) } else if townRoot != "" { - value = fmt.Sprintf("export GT_TOWN_ROOT=%q; unset GT_RIG", townRoot) + value = fmt.Sprintf("export GT_TOWN_ROOT=%q; export GT_ROOT=%q; unset GT_RIG", townRoot, townRoot) } else { - value = "unset GT_TOWN_ROOT GT_RIG" + value = "unset GT_TOWN_ROOT GT_ROOT GT_RIG" } existing[repoRoot] = value