wp-local-docker-v2
wp-local-docker-v2 copied to clipboard
Add sudo to postinstall so that mkcert doesn't get hung up
Description of the Change
This fixes an issue where, on MacOS Ventura (possibly others), if ~/Library/Application Support/mkcert/rootCA.pem
doesn't already exist, a hidden sudo
prompt occurs, and the installation hangs forever.
I attempted to use the sudo.exec()
method, but it causes an error to be thrown - SecTrustSettingsSetTrustSettings: The authorization was denied since no user interaction was possible
- which seems related to this https://developer.apple.com/forums/thread/671582 .
How to test the Change
- Be on a Mac, running Ventura.
- Delete
~/Library/Application Support/mkcert/
from your computer. - Run
sudo -k
to make sure sudo isn't cached. - Run
npm uninstall -g wp-local-docker
to fully remove it. - Run
npm i -g wp-local-docker
to install it from the NPM Registry. Note that after a few mins it just stops. Behind the scenes it's waiting for asudo
password.
To test this branch:
- Repeat steps 1-4 above.
- Switch to this branch and
cd
to the root of this repo. - Edit
src/commands/postinstall.js
and comment out thereturn
statement on line 16. If you don't do this, the local installation will exit before making it to the problem command. - Run
npm i
. You will be prompted for yoursudo
password whennpm run postinstall
is executed, and this will carry through to themkcert
command. - Once complete, verify that you have
~/Library/Application Support/mkcert/rootCA.pem
.
Changelog Entry
Fixed - Installation from NPM Registry would sometimes hang on
mkcert
Credits
Props @ggutenberg
Checklist:
- [x] I agree to follow this project's Code of Conduct.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my change.
- [ ] All new and existing tests pass.