Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(preamble): self-heal GSTACK_ROOT when host globalRoot is absent#1922

Open
onfire7777 wants to merge 1 commit into
garrytan:main from
onfire7777:fix/preamble-gstack-root-fallback
Open

fix(preamble): self-heal GSTACK_ROOT when host globalRoot is absent #1922
onfire7777 wants to merge 1 commit into
garrytan:main from
onfire7777:fix/preamble-gstack-root-fallback

Conversation

@onfire7777

@onfire7777 onfire7777 commented Jun 8, 2026

Copy link
Copy Markdown

Problem

The env-var preamble emitted by scripts/resolvers/preamble/generate-preamble-bash.ts (for usesEnvVars hosts — codex, factory, etc.) resolves the runtime root as:

GSTACK_ROOT="$HOME/<host.globalRoot>" # e.g. ~/.codex/skills/gstack
[ -n "$_ROOT" ] && [ -d "$_ROOT/<localSkillRoot>" ] && GSTACK_ROOT="$_ROOT/<localSkillRoot>"

That assumes gstack is installed at $HOME/<host.globalRoot>. On a shared install where gstack lives at ~/.local/share/gstack and is symlinked per-skill into the host's skills dir (so a full ~/.codex/skills/gstack install dir never exists), the global path doesn't resolve. $GSTACK_BIN/gstack-update-check then silently no-ops (|| true), and the preamble bootstrap can't locate gstack's binaries.

Fix

One additive line: if the resolved GSTACK_ROOT has no executable bin/gstack-update-check but the canonical ${GSTACK_HOME:-$HOME/.local/share/gstack} does, fall back to it.

[ ! -x "$GSTACK_ROOT/bin/gstack-update-check" ] && [ -x "${GSTACK_HOME:-$HOME/.local/share/gstack}/bin/gstack-update-check" ] && GSTACK_ROOT="${GSTACK_HOME:-$HOME/.local/share/gstack}"
  • Standard installs are unaffected — their host path has the binary, so the fallback never triggers.
  • globalRoot is unchanged, so the host-config test pinning .codex/skills/gstack stays green.
  • Only shared / relocated layouts self-heal.

Tests

  • bun test test/gen-skill-docs.test.ts test/host-config.test.ts test/skill-validation.test.ts792 pass / 0 fail.
  • Refreshed the codex + factory ship golden baselines (test/fixtures/golden/{codex,factory}-ship-SKILL.md); the diff is exactly the one added line.

Note: this is a fork PR, so secret-gated eval/E2E CI jobs will run without secrets — the change is preamble-only and covered by the free tier above.

🤖 Generated with Claude Code

trunk-io Bot commented Jun 8, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

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

Copy link
Copy Markdown
Author

/trunk merge

trunk-io[bot] reacted with thumbs down emoji

trunk-io Bot commented Jun 9, 2026

Copy link
Copy Markdown

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>
@onfire7777 onfire7777 force-pushed the fix/preamble-gstack-root-fallback branch from 354ca58 to e3e1a1f Compare June 12, 2026 22:25

Copy link
Copy Markdown
Author

Rebased this branch onto current garrytan/main today and re-ran local verification. Results:

  • bun install --frozen-lockfile — passed
  • bun test test/gen-skill-docs.test.ts test/preamble-compose.test.ts test/resolver-entry.test.ts — 419 pass / 0 fail
  • bun 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /