Skip to content

fix(installer): resolve repo root correctly in scripts under installer/ - #1326

Merged
kovtcharov-amd merged 1 commit into
amd:mainfrom
blackdeathdrow:fix/installer-scripts-repo-root
Jun 1, 2026
Merged

kovtcharov-amd merged 1 commit into
amd:mainfrom
blackdeathdrow:fix/installer-scripts-repo-root

Conversation

@blackdeathdrow

@blackdeathdrow blackdeathdrow commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix repo-root resolution in the two PowerShell scripts under installer/scripts/ - both climbed one parent directory too few after the R097 rename in #731, causing downstream paths ($WebUIDir, $WEBUI_DIR) to point one level short at installer/src/... instead of the real <repo>/src/....

Why

On a fresh Windows checkout:

  • start-agent-ui.ps1 -FrontendOnly invokes npm install / npm run dev against the non-existent installer\src\gaia\apps\webui instead of src\gaia\apps\webui.
  • build-ui-installer.ps1 runs its npm ci, npm run build, electron-forge package/make against the same wrong tree, silently producing a broken installer or failing prerequisite checks at lines 77, 97, 106-108, 132, 149, 158, 166.

Both files live at installer/scripts/, so the correct traversal is $PSScriptRoot\..\.. (two levels up -> repo root), not $PSScriptRoot\.. (one level -> installer/).

Scope note: The bash counterparts (start-agent-ui.sh, build-ui-installer.sh) have the identical off-by-one bug on Linux/macOS. They are deliberately out of scope for this PR (separate platform) and will be addressed in a follow-up.

Linked issue

Closes #1325

Changes

  • installer/scripts/start-agent-ui.ps1: replace the two-line Split-Path -Parent chain (plus the intermediate $ScriptDir variable) with (Resolve-Path "$PSScriptRoot\..\..").Path. $ProjectRoot name is preserved.
  • installer/scripts/build-ui-installer.ps1: change $REPO_ROOT = (Resolve-Path "$PSScriptRoot\..").Path to use ..\.. (same one-character fix). $WEBUI_DIR / $ELECTRON_DIR derive from it, so they get corrected transitively.

Test plan

Automated (cross-platform, no Windows required):

  • PowerShell parser: [System.Management.Automation.Language.Parser]::ParseFile(...) returns no errors for both files.
  • Path resolution sanity check - write a temp script containing the fixed line and confirm it resolves to the repo root:
    `$PSScriptRoot = "`$PWD/installer/scripts"
    `$RepoRoot = (Resolve-Path "`$PSScriptRoot\..\..").Path
    Test-Path (Join-Path `$RepoRoot "src/gaia/apps/webui/package.json")  # expect True
  • git diff is scope-clean: only the two .ps1 files, 3 insertions / 3 deletions.

Manual (Windows reviewer, optional):

  • On a fresh clone, run .\installer\scripts\start-agent-ui.ps1 -FrontendOnly and confirm npm install runs in the correct directory and npm run dev starts.
  • Run .\installer\scripts\build-ui-installer.ps1 -Mode browser and confirm the build completes against the real src\gaia\apps\webui.

Checklist

Both installer/scripts/start-agent-ui.ps1 and installer/scripts/build-ui-installer.ps1
used parent-traversal depth matching their old location at scripts/. After the
R097 rename in #731, both stopped one level short at installer/, causing
\/\ to point at the non-existent installer/src/...

Closes #1325
@github-actions github-actions Bot added the installer Installer changes label Jun 1, 2026
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

The fix is correct — both PowerShell scripts now traverse two parent directories instead of one, so $REPO_ROOT / $ProjectRoot resolves to the real repo root rather than stopping at installer/. The diff is minimal and scope-clean.


Summary

Accurate diagnosis, clean fix. The root cause (both PS1 scripts were only climbing one level from installer/scripts/ to installer/ instead of two to reach <repo>/) is correctly addressed. The $PSScriptRoot reference is also a strict improvement over $MyInvocation.MyCommand.Path in start-agent-ui.ps1, since $PSScriptRoot is PowerShell's canonical, always-absolute directory variable and doesn't change under dot-sourcing. No security concerns, no API surface touched.

Two items worth addressing — one is a follow-up bug in the bash siblings, one is a description inaccuracy that's worth correcting before merge.


Issues Found

🟡 Bash counterparts have the identical off-by-one bug (build-ui-installer.sh:15, start-agent-ui.sh:50)

The same one-level-too-short traversal exists in both shell script counterparts and will produce broken paths on Linux/macOS:

# build-ui-installer.sh:15 — resolves to installer/, not <repo>/
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"

# start-agent-ui.sh:50 — same issue
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"

Both scripts live at installer/scripts/, so the correct fix in both cases is:

REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"

and

PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"

This doesn't block merging the PS1 fix, but should be tracked (a follow-up PR or inclusion here). Users running start-agent-ui.sh --frontend-only on Linux will hit the exact same installer/src/… path error described in the issue.

🟢 PR description claims a variable rename that didn't happen (start-agent-ui.ps1)

"Rename $ProjectRoot → $RepoRoot and update 5 call sites."

The actual diff keeps $ProjectRoot throughout; no rename occurred. The code is fine — $ProjectRoot is a sensible name — but the description is inaccurate. Worth correcting before merge so the PR history is trustworthy.


Strengths

  • Correct fix, right tool: Using $PSScriptRoot is strictly better than the old $MyInvocation.MyCommand.Path chain — it's always absolute and immune to dot-sourcing edge cases.
  • Minimal blast radius: 3 insertions / 3 deletions across exactly the two affected files; no unrelated cleanup, no scope creep.
  • Good root-cause explanation: The PR description pinpoints the #731 rename as the regression source and lists every downstream call site that was broken, making the change easy to verify.

Verdict

Approve with suggestions — the PS1 fix is correct and the bash counterpart bug is a separate issue. Address the description inaccuracy before merge; the bash scripts should be filed as a follow-up or folded in here.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Jun 1, 2026
Merged via the queue into amd:main with commit 83255cf Jun 1, 2026
27 checks passed
@blackdeathdrow
blackdeathdrow deleted the fix/installer-scripts-repo-root branch June 1, 2026 19:18
pull Bot pushed a commit to bhardwajRahul/gaia that referenced this pull request Jun 1, 2026
…taller/ (amd#1332)

## Why this matters

On a fresh Linux/macOS checkout, `start-agent-ui.sh --frontend-only` and
`build-ui-installer.sh` were running `npm`/`electron-forge` against the
non-existent `installer/src/gaia/apps/webui` instead of the real
`src/gaia/apps/webui`, silently producing a broken installer or failing
prerequisite checks. These are the bash counterparts to the two
PowerShell scripts fixed in amd#1326 — flagged in that PR's review as
having the identical off-by-one bug, deliberately deferred to this
follow-up. Both scripts live at `installer/scripts/`, so the correct
traversal is `$SCRIPT_DIR/../..` (two levels up to repo root), not
`$SCRIPT_DIR/..` (one level, stopping at `installer/`).

Follow-up to amd#1326.

## Test plan
- [x] `bash -n` parses both scripts with no errors.
- [x] Path resolution: `cd "$SCRIPT_DIR/../.."` from
`installer/scripts/` resolves to repo root, and
`src/gaia/apps/webui/package.json` is found there.
- [x] `git diff` is scope-clean: only the two `.sh` files, 2 insertions
/ 2 deletions.
- [ ] Manual (Linux reviewer, optional):
`./installer/scripts/start-agent-ui.sh --frontend-only` runs `npm` in
the correct directory; `./installer/scripts/build-ui-installer.sh
--browser` builds against the real `src/gaia/apps/webui`.

Co-authored-by: Ovtcharov <[email protected]>
@kovtcharov-amd kovtcharov-amd mentioned this pull request Jun 1, 2026
5 of 6 tasks
pull Bot pushed a commit to bhardwajRahul/gaia that referenced this pull request Jun 9, 2026
…md#1395)

## Why this matters

amd#1332 fixed the off-by-one repo-root bug in `start-agent-ui.sh` and
`build-ui-installer.sh` (the bash counterparts to the PowerShell fix in
amd#1326), but shipped with only a manual `bash -n` test plan — nothing in
CI stops the `$SCRIPT_DIR/..` → `installer/` regression from creeping
back in if either script is moved or edited again. amd#1328 is still open
precisely because the fix was never pinned.

This adds the regression coverage: a pure-stdlib test that parses both
scripts and asserts the two-levels-up traversal resolves to the real
repo root, that `$WEBUI_DIR`/`$ELECTRON_DIR` point at
`src/gaia/apps/webui` and `src/gaia/electron` (which exist on a fresh
checkout), and that the old one-level traversal would have landed on
`installer/`. No production code changes — the fix is already on `main`.

Closes amd#1328.

## Test plan
- [x] `python -m pytest tests/unit/installer/test_bash_script_paths.py`
— 3 passed against the current (fixed) scripts.
- [x] Sanity: temporarily reverting either script to `$SCRIPT_DIR/..`
makes the corresponding test fail (the guard actually guards).
- [x] `black --check` and `isort --check-only` clean on the new file.

## Out of scope
- The script fix itself (already merged in amd#1332).
- PowerShell counterparts (amd#1326).

---------

Co-authored-by: martin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

installer Installer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: start-agent-ui.ps1 resolves $ProjectRoot one level too shallow - WebUI dir points to non-existent path

2 participants