-
Notifications
You must be signed in to change notification settings - Fork 16.3k
fix(preamble): self-heal GSTACK_ROOT when host globalRoot is absent#1922
fix(preamble): self-heal GSTACK_ROOT when host globalRoot is absent #1922onfire7777 wants to merge 1 commit into
Conversation
Merging to main in this repository is managed by Trunk.
- To merge this pull request, check the box to the left or comment
/trunk mergebelow.
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here
onfire7777
commented
Jun 9, 2026
/trunk merge
An error occurred while submitting your PR to the queue: Only users that are a part of this repo's Trunk organization or have write permissions to the repo can submit a PR to the queue
The env-var preamble (usesEnvVars hosts: codex, factory, ...) sets
GSTACK_ROOT to "$HOME/<host.globalRoot>" (e.g. ~/.codex/skills/gstack) with
only a repo-vendored override. On shared installs where gstack lives at
~/.local/share/gstack and is symlinked per-skill into the host dir, that
global path never exists, so $GSTACK_BIN/gstack-update-check silently no-ops
and the preamble bootstrap can't locate gstack.
Add a fallback: if the resolved GSTACK_ROOT lacks an executable
bin/gstack-update-check but ${GSTACK_HOME:-$HOME/.local/share/gstack} has one,
use that canonical root. Purely additive — standard installs keep their host
path; only shared/broken layouts self-heal.
Refresh codex + factory ship golden baselines (one added line each).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
354ca58 to
e3e1a1f
Compare
onfire7777
commented
Jun 12, 2026
Rebased this branch onto current garrytan/main today and re-ran local verification. Results:
bun install --frozen-lockfile— passedbun test test/gen-skill-docs.test.ts test/preamble-compose.test.ts test/resolver-entry.test.ts— 419 pass / 0 failbun run build— passed
The branch force-push updated cleanly and the PR remains mergeable from the fork. I previously tried /trunk merge, but Trunk rejected it because this account is not in the repo Trunk org / lacks write permission. Ready for maintainer review/queue.
Problem
The env-var preamble emitted by
scripts/resolvers/preamble/generate-preamble-bash.ts(forusesEnvVarshosts — codex, factory, etc.) resolves the runtime root as:That assumes gstack is installed at
$HOME/<host.globalRoot>. On a shared install where gstack lives at~/.local/share/gstackand is symlinked per-skill into the host's skills dir (so a full~/.codex/skills/gstackinstall dir never exists), the global path doesn't resolve.$GSTACK_BIN/gstack-update-checkthen silently no-ops (|| true), and the preamble bootstrap can't locate gstack's binaries.Fix
One additive line: if the resolved
GSTACK_ROOThas no executablebin/gstack-update-checkbut the canonical${GSTACK_HOME:-$HOME/.local/share/gstack}does, fall back to it.globalRootis unchanged, so thehost-configtest pinning.codex/skills/gstackstays green.Tests
bun test test/gen-skill-docs.test.ts test/host-config.test.ts test/skill-validation.test.ts→ 792 pass / 0 fail.test/fixtures/golden/{codex,factory}-ship-SKILL.md); the diff is exactly the one added line.🤖 Generated with Claude Code