A declared pane runs in a login sh whose PATH lacks the tools the city's agents have #81
No reviewers
Labels
No labels
No milestone
No project
No assignees
3 participants
Due date
No due date set.
Dependencies
No dependencies set
Reference
mikluko/rexcity!81
Loading…
Reference in a new issue
No description provided.
Delete branch "worker/rexcity-c7hx9"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A declared pane, in the city tab and in a rig's tab, now finds the tools gc's agents find, and a pane whose declared command changed is replaced at the next start of an agent in its tab.
Cause
Rex starts a declared pane as a login
sh. That shell reads/etc/profileand the user's~/.profile, which on the user's Mac end withPATH=/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:../opt/homebrew/bin, wherebdanddoltlive, is in neither that PATH nor the Rex server's own, sobd list --watchfailed withbd: command not foundevery 5 s.What changed
command = "PATH=/opt/tools/bin:$PATH bd list --watch", or the program's path..pane-commands.<session>, by tab), and a start that finds another command declared for a label replaces the pane: the new one is split where a missing pane goes, then the old one is closed, so a tab is never left empty and the column keeps its order. A pane left by an earlier version has no record and is replaced once, which is how the user's existing broken beads pane gets this fix without being closed by hand. Onlycommandcounts: a different PATH orGC_BINbetween the shells that call the runtime would otherwise make panes flap, and a lost record costs one replacement. In a rig's tab a pane that cannot be replaced is a warning, as for a missing one; in the city tab the start reports it, as it does for a missing pane.Verification
go vetandgo testovercmd/,internal/andpacks/pass, run with a stubrexthat exits non-zero first on PATH; no test touched the user's Rex.bd(found with the runtime's PATH, not found without one). The replacement tests cover both tabs: order kept, the unchanged pane left alone, replaced once when unrecorded, and a tab left with the declared pane alone never emptied. Removing the script's PATH line makes the run test fail. Store tests cover the new record.[Unreleased], a Fixed and a Changed.Main was fetched right before the push and the branch needed no rebase. This goes into 0.33.0 (#79) with the rest.
Bead: rexcity-c7hx9
Review of
7042993217for rexcity-c7hx9: changes required.Required: the 12:06 note of the bead is not met. The note says that what the pane gets "must make gc (the directory of GC_BIN) findable by the programs the command starts, not only by the loop's shell. Add the case to the tests." The pull request passes only the runtime's
PATH, so agccalled from inside a script the command starts (the mail pane'sroles/commands/view/mail/run.sh, line 107) is found only when the runtime'sPATHhappens to hold GC_BIN's directory. Today the supervisor'sPATHstarts with~/.local/bin, so it works by accident; a supervisor started with a launchd or minimalPATH, or a gc run by its full path, breaks it again. Reproduced with the pull request's own argv under the Rex launcher (login-styleexec -a -sh /bin/sh,env -i, the user's ~/.profile) and stubs: runtimePATH=<brew>:/usr/bin:/bin, GC_BIN =<local>/gc->bdanddoltresolve to the stubs, the script'sgcgivesrun.sh: line 3: gc: command not found.What to change:
internal/rpp/citypanes.go,paneArgv/paneScript: put the directory of GC_BIN on the pane'sPATH(prependfilepath.Dir(gcBin(cfg))when GC_BIN is an absolute path, or do it in the script from$0), so a gc started by a program the command runs is the city's gc. Keep the empty-PATH case sane (GC_BIN's directory, then the shell's own).internal/rpp/panepath_test.go: add the note's case: the command runs a script (#!/bin/shfile) that callsgc, with GC_BIN in a directory that is not on the runtime'sPATH; it must reach the GC_BIN stub. A test ofbdthat startsdoltwould also cover the second tool.PATH, and correct the README line that says agca program starts "find[s] gc on the PATH" to say which.Checked and fine: the PATH is set after the login sh's profile, so ~/.profile's
PATH=/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.no longer wins (reproduced); onlyPATHtravels, as an argv element, no other variable and nothing secret; both tabs get it; the command-change replacement (split first, then close, onlycommandcompared, earlier panes replaced once) and the new.pane-commands.<sid>file are compatible both ways (an older binary never reads it; a missing or bad record reads as none); a city without rexcity.toml keeps itslogpane unchanged.go vetandgo test -race ./...pass (head = merge result; main has not moved).7042993217432146c5dfA declared pane, in the city tab and in a rig's tab, now runs its command with the runtime's
PATH(the supervisor's) and with the directory ofGC_BINfirst on it, sobd,doltand agccalled from a script the command starts are all found, whatever a loginsh's profile makes of the shell's ownPATH. A pane whose declared command changed is replaced at the next start of an agent in its tab (new pane first, then the old one closed, keeping its place in the column); a pane an earlier version opened is replaced once.Rework round (review of
7042993):GC_BIN's directory goes first on the pane'sPATH(4th argument of the pane script; with no runtimePATHit comes before the shell's own; skipped whenGC_BINis not absolute).#!/bin/shscript started by the pane's command callsgc, withGC_BIN's directory absent from the runtimePATH, with a stalegcfirst on it, and with no runtimePATH; an unreadable record gives one warning per start and no replacement across three starts. Not covered: the write-failure branch of the probe, as the fake store cannot read but not write.[Unreleased], Fixed and Changed) say so.go vet,go test -raceon rpp/state/cmd and the changelog check pass.Reviewed
432146c5dfin full against rexcity-c7hx9 (notes of 12:06 and 12:13 included): diff, go vet (linux, darwin/arm64), go test -race on the merge into main2829ed8, changelog v1.6.0, login-sh reproduction of the pane script.Re-review of
432146c5dffor rexcity-c7hx9: passes, merged (squash,e626804).Checked:
paneArgvpasses the runtime'sPATHandfilepath.Dir(GC_BIN)(only when absolute) as the script's 3rd and 4th arguments; the script setsPATH=$3, then prepends$4, then exports, before thegcfunction and the loop. Reproduced outside the tests under the Rex launcher's shape (env -i,exec -a -sh /bin/sh, a~/.profilethat setsPATH=/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.), runtimePATH=<brew>:/usr/bin:/bin, GC_BIN in a directory not on it:bdresolves,bdstartsdoltand it resolves, a#!/bin/shscript started by the command reaches the GC_BINgc; the final PATH is<gc dir>:<runtime PATH>.TestAProgramADeclaredPaneStartsFindsTheCitysGCcovers a script callinggcwith GC_BIN's directory absent from the runtime PATH, with a stalegcfirst on it, with no runtime PATH, and a relative GC_BIN (no directory added).forgetCommandson every tracked save) unchanged from the reviewed head and still correct; earlier panes replaced once.[Unreleased], Changed and Fixed) state GC_BIN's directory first and the record-failure behaviour; the old README line about a program-startedgcis corrected.2829ed8(tree identical to the head):go vet ./...,GOOS=darwin GOARCH=arm64 go vet ./...,go test -race ./...pass, run with a failingrexstub first on PATH and the GC_/REX_/REXCITY_/BEADS_/BD_ variables removed; changelog v1.6.0 reports valid. CI green on the head.Follow-ups (none blocking): the probe's write-failure branch has no test, as the PR says (the fake store cannot fail only writes); a GC_BIN directory containing
:would split the PATH (unlikely in practice).Merged by the Operator's reviewing agent under the user's interim mandate of 2026-11-11.