Minor, but may want to first check if the `TMPDIR` env variable is set.
May also want to use `mkdtemp` in case the update fails and you try to do the update again.