From e1eb1b4c404ba4c0d1139ebdc4e2c86c2b1e9e4a Mon Sep 17 00:00:00 2001 From: JamBalaya56562 Date: Thu, 30 Apr 2026 02:13:34 +0900 Subject: [PATCH] fix: write absolute extension_dir to php.ini on Windows install Closes #19. Composer setup launches php.exe from the user's terminal CWD, so a relative extension_dir = "./ext" in php.ini resolves to /ext instead of the install dir. php_openssl.dll is then unfindable, the openssl extension fails to load, Composer's HTTPS download dies, and post_install.lua reports 'Failed to install composer.' Write the extension_dir as an absolute path so php.exe locates ext/ regardless of CWD. --- hooks/post_install.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hooks/post_install.lua b/hooks/post_install.lua index 9e11736..5e8e422 100644 --- a/hooks/post_install.lua +++ b/hooks/post_install.lua @@ -19,7 +19,14 @@ function InstallComposerForWin(path) if err ~= nil then error(err) end - content = content:gsub(';%s*extension_dir = "ext"', 'extension_dir = "./ext"') + -- Use an absolute extension_dir so php.exe can locate php_openssl.dll + -- regardless of which CWD it was launched from. The composer-setup + -- step below invokes php.exe from the user's shell CWD, so a relative + -- "./ext" path resolves to the wrong directory and fails to load + -- openssl, breaking the HTTPS download Composer needs. + local ext_dir = (path .. "\\ext"):gsub("\\", "/") + content = content:gsub(';%s*extension_dir = "ext"', + function() return 'extension_dir = "' .. ext_dir .. '"' end) content = content:gsub(';extension=openssl', 'extension=openssl') content = content:gsub(';extension=php_openssl.dll', 'extension=php_openssl.dll') _, err = util.write_file(path .. '\\php.ini', content)