Fix avdmanager and sdkmanager on Windows - #110
SunkenInTime wants to merge 1 commit into
Conversation
On Windows the cmdline-tools ship as .bat wrappers. The path helpers pointed at the extension-less name, which Node cannot find, and even with the extension Node refuses to spawn a batch file without a shell. Append .bat on win32 and run those two tools through cmd.exe as a single quoted command line. adb and emulator are native binaries and already resolve to their .exe. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Independent confirmation on a second Windows machine — including the part that is I hit the same failure and had written a local patch before finding this PR. My Measured with
So both halves of the diagnosis reproduce independently: the missing One note on the control flow, for whoever reviews this: routing only Before the measurement above I ran the same probe with a wrong SDK path by |
Problem
On Windows the Android cmdline-tools ship as
avdmanager.batandsdkmanager.bat.sdk-paths.tsbuilds the extension-less path, so every call fails and the Hub lists no emulators:Appending
.batalone is not enough. Node refuses to spawn a batch file without a shell (spawn EINVAL, since 18.20 / 20.12).Fix
sdk-paths.ts: append.battoavdmanagerandsdkmanageronwin32. A trailingplatformparameter (defaults toprocess.platform) keeps the helpers testable from any OS.exec-sdk-tool.ts: a.batpath runs throughcmd.exeas one quoted command line; anything else still goes throughexecFileexactly as before.timeoutandsignalpass through in both cases.adbandemulatorare left alone. Windows resolves the missing.exeon its own (checked on this machine).Proof
Windows 11, Node 24.13, Android SDK with
cmdline-tools/latest.listDevices()bundled frommainand from this branch, run under Node:The Hub CLI built from this branch,
GET /api/devices:{"simulators":[],"emulators":[{"id":"emulator-5554","name":"T3Code_Pixel_8_API_36","version":"Android 16.0","platform":"android","booted":true,"physical":false,"supported":true}],"errors":[]}GET /api/new-device-options, which goes throughsdkmanager --list_installedandavdmanager list device, returns the installed system image and device profiles.Note: Bun's
child_processresolves.batfiles itself, so this never shows up underbun testorbun run. The published CLI runs under Node, where it does.Tests
exec-sdk-tool.test.ts: quoting rules, direct spawn of native binaries, and a Windows-only case that runs a real.batand checks that;in a system image package and spaces in a path survive intact.sdk-paths.test.ts:.batonwin32, bare name elsewhere.bun test,tsc --noEmit, andoxlintpass inhub-android-utils. The pre-existingsdk-pathsassertions compare POSIX strings, so they already fail on a Windows checkout; left as is.🤖 Generated with Claude Code