fix: support Windows installation - #9
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces Windows compatibility to the post_install.lua hook by conditionally executing Windows-specific shell commands (such as move, robocopy, and rmdir) and adjusting the executable verification for sdkmanager.bat. The reviewer suggested a significant simplification to the directory movement logic: instead of creating the target directory and moving its contents (which relies on robocopy on Windows and wildcards on Unix), the code can create the parent directory and rename/move the entire temporary directory directly. This approach avoids complex tools, prevents wildcard issues, and eliminates the need for manual cleanup.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if is_windows then | ||
| -- Move current rootPath to temp location | ||
| os.execute('move "' .. root_path .. '" "' .. temp_path .. '"') | ||
|
|
||
| -- Recreate rootPath with proper structure | ||
| os.execute("mkdir -p " .. target_path) | ||
| -- Recreate rootPath with proper structure | ||
| os.execute('mkdir "' .. target_path .. '"') | ||
|
|
||
| -- Move contents from temp to target | ||
| os.execute("mv " .. temp_path .. "/* " .. target_path .. "/") | ||
| -- Move contents from temp to target (/MOVE also removes temp) | ||
| os.execute('robocopy "' .. temp_path .. '" "' .. target_path .. '" /E /MOVE >nul') | ||
|
|
||
| -- Clean up temp | ||
| os.execute("rm -rf " .. temp_path) | ||
| -- Clean up temp if robocopy left it behind | ||
| os.execute('if exist "' .. temp_path .. '" rmdir /s /q "' .. temp_path .. '"') | ||
| else | ||
| -- Move current rootPath to temp location | ||
| os.execute('mv "' .. root_path .. '" "' .. temp_path .. '"') | ||
|
|
||
| -- Recreate rootPath with proper structure | ||
| os.execute('mkdir -p "' .. target_path .. '"') | ||
|
|
||
| -- Move contents from temp to target | ||
| os.execute('mv "' .. temp_path .. '"/* "' .. target_path .. '/"') | ||
|
|
||
| -- Clean up temp | ||
| os.execute('rm -rf "' .. temp_path .. '"') | ||
| end |
There was a problem hiding this comment.
Instead of creating the target directory and moving the contents of the temp directory (which requires using robocopy on Windows and wildcard expansion * on Unix), you can simplify this significantly by creating only the parent directory (cmdline-tools) and then moving/renaming the entire temp_path directory to target_path.
This approach has several advantages:
- Avoids
robocopy:robocopyis heavy and returns non-standard exit codes (e.g., exit code1or3on success), which can sometimes be misinterpreted as failures. - Avoids Wildcard Issues: On Unix,
mv temp/* target/does not move hidden files (files starting with.) by default and can fail if there are too many files or if the directory is empty. - No Cleanup Needed: Moving the entire directory automatically removes the temp directory, eliminating the need for
rmdirorrm -rfcleanup steps. - Atomic & Faster: Moving/renaming a directory is an atomic operation and is instantaneous compared to copying files individually.
local parent_path = file.join_path(root_path, "cmdline-tools")
if is_windows then
-- Move current rootPath to temp location
os.execute('move "' .. root_path .. '" "' .. temp_path .. '"')
-- Recreate parent directory structure
os.execute('if not exist "' .. parent_path .. '" mkdir "' .. parent_path .. '"')
-- Move temp to target (renames the directory)
os.execute('move "' .. temp_path .. '" "' .. target_path .. '"')
else
-- Move current rootPath to temp location
os.execute('mv "' .. root_path .. '" "' .. temp_path .. '"')
-- Recreate parent directory structure
os.execute('mkdir -p "' .. parent_path .. '"')
-- Move temp to target (renames the directory)
os.execute('mv "' .. temp_path .. '" "' .. target_path .. '"')
end
There was a problem hiding this comment.
Comment addressed and tested in commit 68f5468
post_install.lua
Summary
post_install.luasdkmanager.batduring installation verificationCI
The integration matrix installs Android SDK command-line tools 13.0 and runs
sdkmanager --versionon:The existing unit-test job also remains enabled.
Issues addressed