Skip to content

Commit dd17bb9

Browse files
authored
Force removal of orphaned valet.sock file
When switching PHP versions the valet.sock file may not be removed if the linked PHP process doesn't get shut down properly. This can happen when Homebrew switches default `php` version aliases and if one has started multiple homebrew PHP instances under different permission levels or different users. This patch merely forces the .sock file's removal when switching versions. In very rare cases a filesystem lock may prevent the file's proper removal, in which case a reboot might be required. To prevent these issues, keep Homebrew up-to-date by running `brew upgrade` on a regular basis (weekly is good).
1 parent 86a830a commit dd17bb9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

cli/Valet/PhpFpm.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ function useVersion($version, $force = false)
202202

203203
$this->stopRunning();
204204

205+
// remove any orphaned valet.sock files that PHP didn't clean up due to version conflicts
206+
$this->files->unlink(VALET_HOME_PATH.'/valet.sock');
207+
$this->cli->quietly('sudo rm ' . VALET_HOME_PATH.'/valet.sock');
208+
205209
// ensure configuration is correct and start the linked version
206210
$this->install();
207211

0 commit comments

Comments
 (0)