Skip to content

fix(windows): resolve PHP install failures and prevent false CI coverage#65

Merged
rozsazoltan merged 27 commits into
verzly:masterfrom
Artemeey:fix-windows-php-install-quoting
Jun 24, 2026
Merged

fix(windows): resolve PHP install failures and prevent false CI coverage#65
rozsazoltan merged 27 commits into
verzly:masterfrom
Artemeey:fix-windows-php-install-quoting

Conversation

@Artemeey

@Artemeey Artemeey commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Command:

mise install php@8.5

Error message:

mise ERROR Failed to install vfox:php@8.5: runtime error: ...ppData\Local\mise\plugins\php\hooks/post_install.lua:44: 

Failed to install PHP.

💡 Tip: Run 'PHP_VERBOSE=1 mise install php@8.5.8RC1' to show commands, failure summaries, and log paths.
→ See: https://github.com/verzly/mise-php#debugging

stack traceback:
        [C]: in function 'error'
        ...ppData\Local\mise\plugins\php\hooks/post_install.lua:44: in upvalue 'install_php_for_windows'
        ...ppData\Local\mise\plugins\php\hooks/post_install.lua:22: in function 'PLUGIN.PostInstall'
        crates\vfox\src\plugin.rs:188:2: in main chunk
mise ERROR Version: 2026.6.11 windows-x64 (2026-06-16)
mise ERROR Run with --verbose or MISE_VERBOSE=1 for more information

Updated by @rozsazoltan

Resolves #68

Summary

This PR fixes Windows PHP installation failures and improves CI coverage so Windows install regressions are caught reliably.

The original issue was reported with:

mise install php@8.5

which failed during the Windows post-install step with:

Failed to install PHP.

A previous Windows check appeared green, but the released/latest version still failed in real Windows usage. This PR focuses on making the Windows install path work correctly and ensuring the workflow validates the same behavior users rely on.

Changes

  • Reworks Windows PHP installation to avoid fragile shell-script based execution.

  • Uses mise/vfox Lua runtime primitives for download, extraction, file handling, and command execution.

  • Avoids temporary command runner files.

  • Keeps only the required Windows runtime wrappers:

    • pie.bat
    • composer.bat
  • Validates the installed php.exe after installation.

  • Fixes Windows path quoting behavior, including paths containing spaces.

  • Centralizes post-install package setup for PECL, PIE, PIE extensions, and Composer.

  • Deduplicates shared Lua helper functions.

  • Improves Windows CI coverage so install checks run under spaced mise paths and validate the actual installed PHP binary.

CI / regression coverage

The Windows workflow now exercises a more realistic install path and checks that the resolved PHP binary comes from the expected mise install directory.

This is intended to prevent misleading CI results where Windows checks pass even though the real Windows installation path is broken.

Notes

The Windows implementation intentionally avoids executing temporary command files. The generated .bat files are limited to runtime wrappers required for Windows usage of PIE and Composer.

This PR does not build PHP from source on Windows. It installs official PHP Windows ZIP releases and validates the resulting runtime.

@rozsazoltan rozsazoltan added the needs-ci Triggers the CI test workflow label Jun 20, 2026
@Artemeey Artemeey force-pushed the fix-windows-php-install-quoting branch from 4feef07 to 98edc0b Compare June 20, 2026 22:49
@Artemeey

Copy link
Copy Markdown
Contributor Author

Command os.execute(installCmd) split by spaces and ignore quotes.
This can lead to problems with paths containing spaces.

@rozsazoltan rozsazoltan added needs-ci Triggers the CI test workflow and removed needs-ci Triggers the CI test workflow labels Jun 21, 2026
@rozsazoltan

Copy link
Copy Markdown
Contributor

Thanks for working on this!

Good catch on os.execute(installCmd) splitting the command by spaces and ignoring quotes.

The change looks reasonable from my side. I'll also review my gh workflows soon. It's possible I made some assumptions during setup and didn’t fully account for Windows-specific behavior, limitations, or differences from a real Windows environment.

@Artemeey

Copy link
Copy Markdown
Contributor Author

Info

Windows 11
Git Bash / PowerShell

mise doctor:

version: 2026.6.11 windows-x64 (2026-06-16)
shims_on_path: yes
self_update_available: yes
No problems found

Analyze

Single quotes break the command when it is executed through cmd /c.

Example: cmd /c powershell -NoProfile -ExecutionPolicy Bypass -Command 'Invoke-WebRequest -Uri https://github.com/php/pie/releases/latest/download/pie.phar -OutFile C:\Users\<user>\AppData\Local\mise\installs\php\8.5.3\pie.phar'

Double quotes escapes by os.execute() with cmd /c.

Expected: cmd /c powershell -NoProfile -ExecutionPolicy Bypass -Command "Invoke-WebRequest -Uri https://github.com/php/pie/releases/latest/download/pie.phar -OutFile C:\Users\<user>\AppData\Local\mise\installs\php\8.5.3\pie.phar"

Actual: cmd /c powershell -NoProfile -ExecutionPolicy Bypass -Command \"Invoke-WebRequest -Uri https://github.com/php/pie/releases/latest/download/pie.phar -OutFile C:\Users\<user>\AppData\Local\mise\installs\php\8.5.3\pie.phar\"

Понял. Лучше так:

Resolve

Use temporary bat files for quoted control constructs.
Selected as the most compact solution.

@rozsazoltan rozsazoltan removed the needs-ci Triggers the CI test workflow label Jun 22, 2026
@rozsazoltan rozsazoltan added the needs-ci Triggers the CI test workflow label Jun 24, 2026
Replace the PowerShell-based Windows PHP installer with a Lua
implementation that uses shared download, extraction, quoting, and
command execution helpers.

Move PECL, PIE, and Composer installation logic into a dedicated
php_packages module so tools.lua stays focused on reusable filesystem,
download, and process utilities.

Improve Windows install reliability by quoting PowerShell and cmd
arguments explicitly, and verify the install flow under a MISE_DATA_DIR
that contains spaces.

Extend CI coverage for Windows spaced mise directories and add cache
workflow maintenance issues for new PHP major/minor series that may
require Windows installer mapping updates.
Move PECL, PIE, PIE extension, and Composer installation into the shared
PostInstall flow after the PHP runtime has been installed.

This keeps source, Windows, and static PHP installers focused on
installing
and validating the runtime, while applying the package/tooling
post-install
policy in one place.

Source builds still run cleanup after package installation to preserve
the
previous install order.
Move shared version comparison, shell quoting, file copying, and static
prebuilt option helpers into reusable modules.

This reduces duplicated helper logic across source, static, package, and
hook code while keeping PHP package installation logic separate from
generic tools.

Also centralizes Windows PHAR wrapper generation for PIE and Composer
without introducing temporary command runner files.
Move the Windows spaced MISE_* directory setup after jdx/mise-action has
installed mise.

This keeps the regression coverage for plugin installs under paths
containing
spaces, while avoiding a Windows cross-device rename failure during
mise-action
setup itself.
@rozsazoltan rozsazoltan changed the title fix: os.execute(installCmd) fix(windows): resolve PHP install failures and prevent false CI coverage Jun 24, 2026
@rozsazoltan rozsazoltan merged commit df49394 into verzly:master Jun 24, 2026
42 checks passed
@Artemeey

Artemeey commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Error is not displayed:

mise [php] Enabled sodium
mise [php] Enabled sqlite3
mise [php] Enabled tidy
mise [php] Enabled xsl
mise [php] Enabled zip
mise [php] PHP installation complete!
mise [php] Installing PIE...
mise [php] PIE installation complete!
mise [php] Installing PIE extension: phpredis/phpredis...
mise [php] Installing PIE extension: maxmind-db/reader-ext...
mise [php] Installing PIE extension: imagick/imagick...
mise [php] PIE extensions installation complete!
mise [php] Installing Composer...
mise [php] Note: Composer installation output is hidden. Set PHP_VERBOSE=1 to see full output.
mise [php] Composer installation complete!
plugin:php      clone https://github.com/verzly/mise-php/                                                                           ✔
php@8.5.5       install                                                                                                             ✔

artem@Machenike17 MINGW64 ~/PhpstormProjects/topvisor/topvisor.com/php-fpm (master)
$ php -m | grep phpredis

PIE extension no intsalled

Current working branch with check status code: https://github.com/Artemeey/mise-php/tree/fix-windows-php-install-quoting-2

Example get status code: https://github.com/Artemeey/mise-php/blob/d28c629261f69518521a751f0a824ad2a735a62c/lib/tools.lua#L76

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci Triggers the CI test workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows PHP install fails while CI does not reliably catch real Windows install regressions

2 participants