Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinstalling or Uninstalling Windows extensions fails #190

Open
asgrim opened this issue Feb 25, 2025 · 3 comments · May be fixed by #199
Open

Reinstalling or Uninstalling Windows extensions fails #190

asgrim opened this issue Feb 25, 2025 · 3 comments · May be fixed by #199
Assignees
Labels
maintainer investigating This ticket is being investigated by maintainers. Please check with us before contributing PRs etc!

Comments

@asgrim
Copy link
Collaborator

asgrim commented Feb 25, 2025

Reinstalling or uninstalling an extension in Windows does not work currently.

This is because when DLL is loaded in Windows, we cannot unload it from PHP in order to free Windows' lock on the file. If you attempt to overwrite or uninstall the DLL in Windows, you will get an unhelpful/cryptic error like:

PHP Warning:  copy(C:\tools\php\ext\php_example_pie_extension.dll): Failed to
open stream: Resource temporarily unavailable in src\Installing\WindowsInstall.php on line 127

(this specific error is trying to re-install an ext that is already installed)

After some searching, it seems this is because the DLL is loaded and therefore cannot be "written" whilst loaded. One potential solution here is to relaunch PHP without the extension loaded. I believe Composer has a mechanism to reload without xdebug (for performance) so it may be possible to leverage that.

@asgrim asgrim added the bug Something isn't working label Feb 25, 2025
@asgrim asgrim self-assigned this Feb 25, 2025
@asgrim asgrim changed the title Windows Reinstalling or Uninstalling Windows extensions Feb 25, 2025
@asgrim asgrim changed the title Reinstalling or Uninstalling Windows extensions Reinstalling or Uninstalling Windows extensions fails Feb 25, 2025
asgrim added a commit to asgrim/pie that referenced this issue Feb 25, 2025
@mickverm
Copy link
Contributor

This issue is what currently prevents me from efficiently using PIE efficiently on Windows. It now requires me to have a separate PHP installation to update extensions, which often has me looking back to the documentation or one of my previous MRs (#70) to find the correct command.

@asgrim asgrim added maintainer investigating This ticket is being investigated by maintainers. Please check with us before contributing PRs etc! and removed bug Something isn't working labels Feb 25, 2025
asgrim added a commit to asgrim/pie that referenced this issue Feb 27, 2025
asgrim added a commit to asgrim/pie that referenced this issue Feb 27, 2025
asgrim added a commit to asgrim/pie that referenced this issue Feb 28, 2025
@asgrim asgrim linked a pull request Mar 6, 2025 that will close this issue
@asgrim
Copy link
Collaborator Author

asgrim commented Mar 6, 2025

@mickverm potential fix in #199 - feel free to try it out! :)

@mickverm
Copy link
Contributor

mickverm commented Mar 7, 2025

I can confirm that it works, and the new version is used after I restart my Apache service.

PS C:\Users\mv\Documents\GitHub\pie> php .\bin\pie install mongodb/mongodb-extension          
This command may need elevated privileges, and may prompt you for your password.
You are running PHP 8.4.4
Target PHP installation: 8.4.4 ts, vs17, on Windows x86_64 (from C:\Apache24\php\php.exe)
Found package: mongodb/mongodb-extension:1.21.0 which provides ext-mongodb
Found prebuilt archive: https://github.com/mongodb/mongo-php-driver/releases/download/1.21.0/php_mongodb-1.21.0-8.4-ts-vs17-x86_64.zip
Extracted mongodb/mongodb-extension:1.21.0 source to: C:\Users\mv\AppData\Roaming\PIE\php8.4_c0065e13d315ca5720a6c61b9087bc89\vendor/mongodb/mongodb-extension
Nothing to do on Windows, prebuilt DLL found: C:\Users\mv\AppData\Roaming\PIE\php8.4_c0065e13d315ca5720a6c61b9087bc89\vendor/mongodb/mongodb-extension/php_mongodb-1.21.0-8.4-ts-vs17-x86_64.dll
Copied DLL to: C:\Apache24\php\ext\php_mongodb.dll
Copied PDB to: C:\Apache24\php\ext\php_mongodb.pdb
Copied extras: C:\Apache24\php\extras\mongodb\CONTRIBUTING.md
Copied extras: C:\Apache24\php\extras\mongodb\CREDITS
Copied extras: C:\Apache24\php\extras\mongodb\LICENSE
Copied extras: C:\Apache24\php\extras\mongodb\php_mongodb-1.21.0-8.4-ts-vs17-x86_64.dll.sig
Copied extras: C:\Apache24\php\extras\mongodb\README.md
Copied extras: C:\Apache24\php\extras\mongodb\THIRD_PARTY_NOTICES
✅ Extension is enabled and loaded in C:\Apache24\php\php.exe

PS C:\Users\mv\Documents\GitHub\pie> php .\bin\pie uninstall mongodb/mongodb-extension
This command may need elevated privileges, and may prompt you for your password.
You are running PHP 8.4.4
Target PHP installation: 8.4.4 ts, vs17, on Windows x86_64 (from C:\Apache24\php\php.exe)
👋 Removed extension: C:\Apache24\php\ext\php_mongodb.dll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintainer investigating This ticket is being investigated by maintainers. Please check with us before contributing PRs etc!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants