Skip to content

2.1.4 — Config file reliability

Latest

Choose a tag to compare

@FernandoEbert FernandoEbert released this 12 Nov 14:35
faae9af

Config file reliability

Fixes a case where ~/.config/valet/config.json could be left empty, after which every valet command (including valet update) failed with:

PHP Fatal error: Uncaught TypeError: Valet\Configuration::read(): Return value must be of type array, null returned

Valet rewrote config.json on every command, truncating it before writing. If the process was interrupted in between (killed by a timeout, crash, full disk), the file was left with 0 bytes (#14).

Change Description
Atomic writes config.json is written to a temporary file, flushed to disk and renamed over the original. An interrupted write keeps the previous file intact. Symlinks are followed and the file mode is preserved.
No-op prune Commands no longer rewrite config.json unless a parked path was actually removed. Read-only commands such as valet state don't touch the disk anymore, which matters for tools that poll Valet.
Clear error An empty or invalid config.json now prints which file is broken and how to recover, and exits with status 1, instead of a stack trace.

Other changes

  • Filesystem::putAtomic() / putAtomicAsUser()
  • ConfigurationException
  • 8 new tests

Recovering an empty config.json

If you already hit the error, recreate the file before upgrading. See Troubleshooting.

Upgrading

composer global update fernandoebert/valet-linux-plus