local_instrumented.sh resolved GRADLEW as an absolute path from its own script
location, but never made that the build's project directory. The gradlew wrapper
picks the project to build from the process's current directory, not from the wrapper
script's own location — so invoking the helper from a CWD outside its tree (e.g. another
worktree) silently built the wrong repo's :app. That's exactly what a peer agent hit:
first run built the main repo's APK and got a ClassNotFoundException for a test class
that only existed in the intended worktree; re-running with CWD manually set to the
worktree fixed it.
Fix
Added one cd "${REPO_ROOT}" (with a die on failure) right after the existing
preconditions, before gradlew is invoked. REPO_ROOT was already resolved correctly
and CWD-independently (via SCRIPT_DIR/BASH_SOURCE), so this is the minimal change:
make the actual build target that root too, instead of only using it to locate the
wrapper script. Everything else (orphan-kill preamble, manual boot, EXIT-trap teardown)
is untouched.
Also updated local_instrumented.README.md's usage note, which previously said "from
the repo root" — that's no longer a requirement, so the note now explains the
CWD-independence and why it matters (running the right worktree's copy of the script).
Validation
No emulator boot (script/review only, per the ticket):
bash -n .claude/skills/preflight/local_instrumented.sh — syntax OK.
Manual review of the diff and full script confirming every other path used
(AVD_HOME, JDK_HOME, EMU_LOG) is already absolute, so the new cd doesn't affect
anything else in the script.
shellcheck was not available locally, so it was skipped (not required by the ticket
unless available).
Closes #284
## What
`local_instrumented.sh` resolved `GRADLEW` as an absolute path from its own script
location, but never made that the *build's* project directory. The gradlew wrapper
picks the project to build from the process's current directory, not from the wrapper
script's own location — so invoking the helper from a CWD outside its tree (e.g. another
worktree) silently built the wrong repo's `:app`. That's exactly what a peer agent hit:
first run built the main repo's APK and got a `ClassNotFoundException` for a test class
that only existed in the intended worktree; re-running with CWD manually set to the
worktree fixed it.
## Fix
Added one `cd "${REPO_ROOT}"` (with a `die` on failure) right after the existing
preconditions, before `gradlew` is invoked. `REPO_ROOT` was already resolved correctly
and CWD-independently (via `SCRIPT_DIR`/`BASH_SOURCE`), so this is the minimal change:
make the actual build target that root too, instead of only using it to locate the
wrapper script. Everything else (orphan-kill preamble, manual boot, EXIT-trap teardown)
is untouched.
Also updated `local_instrumented.README.md`'s usage note, which previously said "from
the repo root" — that's no longer a requirement, so the note now explains the
CWD-independence and why it matters (running the right worktree's copy of the script).
## Validation
No emulator boot (script/review only, per the ticket):
- `bash -n .claude/skills/preflight/local_instrumented.sh` — syntax OK.
- Manual review of the diff and full script confirming every other path used
(`AVD_HOME`, `JDK_HOME`, `EMU_LOG`) is already absolute, so the new `cd` doesn't affect
anything else in the script.
- `shellcheck` was not available locally, so it was skipped (not required by the ticket
unless available).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes #284
What
local_instrumented.shresolvedGRADLEWas an absolute path from its own scriptlocation, but never made that the build's project directory. The gradlew wrapper
picks the project to build from the process's current directory, not from the wrapper
script's own location — so invoking the helper from a CWD outside its tree (e.g. another
worktree) silently built the wrong repo's
:app. That's exactly what a peer agent hit:first run built the main repo's APK and got a
ClassNotFoundExceptionfor a test classthat only existed in the intended worktree; re-running with CWD manually set to the
worktree fixed it.
Fix
Added one
cd "${REPO_ROOT}"(with adieon failure) right after the existingpreconditions, before
gradlewis invoked.REPO_ROOTwas already resolved correctlyand CWD-independently (via
SCRIPT_DIR/BASH_SOURCE), so this is the minimal change:make the actual build target that root too, instead of only using it to locate the
wrapper script. Everything else (orphan-kill preamble, manual boot, EXIT-trap teardown)
is untouched.
Also updated
local_instrumented.README.md's usage note, which previously said "fromthe repo root" — that's no longer a requirement, so the note now explains the
CWD-independence and why it matters (running the right worktree's copy of the script).
Validation
No emulator boot (script/review only, per the ticket):
bash -n .claude/skills/preflight/local_instrumented.sh— syntax OK.(
AVD_HOME,JDK_HOME,EMU_LOG) is already absolute, so the newcddoesn't affectanything else in the script.
shellcheckwas not available locally, so it was skipped (not required by the ticketunless available).
🤖 Generated with Claude Code