Skip to content

fix: support Windows installation - #9

Merged
jdx merged 11 commits into
mise-plugins:mainfrom
MattP-Nocturnal:main
Jul 16, 2026
Merged

fix: support Windows installation#9
jdx merged 11 commits into
mise-plugins:mainfrom
MattP-Nocturnal:main

Conversation

@MattP-Nocturnal

@MattP-Nocturnal MattP-Nocturnal commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add Windows support to post_install.lua
  • handle sdkmanager.bat during installation verification
  • pass Windows paths through environment variables to PowerShell so paths containing spaces remain safe
  • quote Unix paths and keep executable permission handling Unix-only
  • link the checked-out plugin in CI so pull requests test their own code

CI

The integration matrix installs Android SDK command-line tools 13.0 and runs sdkmanager --version on:

  • Ubuntu
  • macOS
  • Windows

The existing unit-test job also remains enabled.

Issues addressed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread hooks/post_install.lua
Comment on lines +30 to +54
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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:

  1. Avoids robocopy: robocopy is heavy and returns non-standard exit codes (e.g., exit code 1 or 3 on success), which can sometimes be misinterpreted as failures.
  2. 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.
  3. No Cleanup Needed: Moving the entire directory automatically removes the temp directory, eliminating the need for rmdir or rm -rf cleanup steps.
  4. 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment addressed and tested in commit 68f5468

@jdx jdx changed the title Windows-compatible post_install.lua fix: support Windows installation Jul 16, 2026
@jdx
jdx merged commit ebdf31d into mise-plugins:main Jul 16, 2026
4 checks passed
This was referenced Jul 16, 2026
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.

post_install.lua verification fails on Windows: looks for sdkmanager without .bat Support Windows

2 participants