Pass through the env to file.patch state

Fixes #7452.