Files are written to disk. In a cloud setup that mean possibly leaking credentials when your disk is re-assigned to another tenant.
Yes, cloud provider are supposed to properly erase hard drive before reassigning. Can you be 100% sure they do though ?
With environment variable in RAM the problem is moot. Committing and/or generating .env in production system is completely missing the point.