Skip to content

Resolve sdkmanager by its known layouts, and say what is there when it is not - #526

Merged
bernardladenthin merged 1 commit into
mainfrom
local/fix-sdkmanager-depth
Oct 11, 2026
Merged

bernardladenthin merged 1 commit into
mainfrom
local/fix-sdkmanager-depth

Conversation

@bernardladenthin

Copy link
Copy Markdown
Owner

My fix in #519 was off by one. It searched with find "$root/cmdline-tools" -maxdepth 2, but the
file sits at cmdline-tools/latest/bin/sdkmanager — three levels below cmdline-tools — so the
search stopped at the bin directory and reported the file missing while it was there.

Run 38164077038 said so in one line:

##[error]sdkmanager not found -- looked on PATH and under ANDROID_HOME='/usr/local/lib/android/sdk', …

Which is exactly what #519's other half bought. The message named the right cause, so the real
defect took one look instead of another round of suspecting dl.google.com.

The change

the three known layouts in order — cmdline-tools/latest/bin, cmdline-tools/<version>/bin, the old tools/bin correct, readable, and cannot be off by one again
the outer loop stops once one root answers the inner break leaves only the inner loop, so a later root could otherwise overwrite the found path
that guard is an if, not a trailing test && break under set -e a trailing && list ends the step the moment the test is false
when nothing is found, list what IS under each root the part #519 still lacked

That last one is the lesson repeating: naming only the places searched leaves three different
causes — no directory, no version subdirectory, no file — behind one message, and a reader cannot tell
them apart. The listing loop deliberately has no early break, so it reports every root.

Validated locally against five layouts

layout result
cmdline-tools/latest/bin (what CI has) found
a version directory, no latest found
the old tools/bin found
an empty SDK fails, as it must
first root empty, second carries the file found in the second

One trap worth knowing before testing such a step here

On this Windows checkout chmod +x does not stick on a plain file (ls -l still shows
rw-r--r--), so [ -x ] answers false. The first run of that probe called all five layouts broken
— including the one that demonstrably works in CI. The fixtures needed a #!/bin/sh line: it was the
harness, not the logic. Recorded in TODO.md.

Still unproven

The emulator jobs have not been green since the pre-install step was added, so the thing it was built
to survive — the corrupt archive of run 38069595101 — remains unverified. Said in TODO.md rather
than implied by a green run.

check-run-scripts.py 161 scripts clean (it bash -ns both copies), check-release-gate.py 0
violations, check-natives.py 0 disagreements.

🤖 Generated with Claude Code

https://claude.ai/code/session_01E2h8gXyyE5UeimkL9vQv9G

…t is not

My fix in #519 was off by one. It searched with find -maxdepth 2 under cmdline-tools, but the file sits at cmdline-tools/latest/bin/sdkmanager, three levels down -- so the search stopped at the bin directory and reported the file missing while it was there. Run 38164077038 said so in one line, which is what that PR's other half bought: the message named the right cause, so the real defect took one look instead of another suspicion about dl.google.com.

This replaces the find with the three known layouts in order -- cmdline-tools/latest/bin, cmdline-tools/<version>/bin and the old tools/bin -- which is both correct and readable, and cannot be off by one again. The outer loop over ANDROID_HOME, ANDROID_SDK_ROOT and the image path now stops once one answers: the inner break leaves only the inner loop, so a later root could otherwise overwrite the found path. That guard is an if rather than a trailing test-and-break, which under set -e would end the step the moment the test is false.

And the part #519 still lacked: when nothing is found, the step now lists what IS under each root. Naming only the places searched leaves three different causes -- no directory, no version subdirectory, no file -- behind one message, and a reader cannot tell them apart. The listing loop deliberately has no early break, so it reports every root.

Validated locally against five faked layouts: latest (what CI has), a version directory without latest, the old tools/bin, an empty SDK that must fail, and a first root that is empty with the second carrying the file. Both copies of the step are fixed identically; check-run-scripts.py parses all 161 scripts, the release gate and the natives list are unchanged.

A trap recorded in TODO.md for whoever tests such a step on this checkout: chmod +x does not stick on a plain file here, so [ -x ] answers false and the first run of that probe called all five layouts broken -- including the one that demonstrably works in CI. The fixtures needed a shebang; it was the harness, not the logic.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01E2h8gXyyE5UeimkL9vQv9G
@sonarqubecloud

Copy link
Copy Markdown

@bernardladenthin
bernardladenthin merged commit 58ba961 into main Oct 11, 2026
36 of 67 checks passed
@bernardladenthin
bernardladenthin deleted the local/fix-sdkmanager-depth branch October 11, 2026 19:22

This branch had an error being deployed

1 failed and 1 active deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant