I found out that it was a Windows Security issue in the end... I enabled controlled folder access. To disable this follow these steps:
- Settings > Update & Security (Windows 10) or Privacy & Security (Windows 11) > Windows Security > Virus & threat protection.
- Under Virus & threat protection settings, select Manage settings.
- Under Controlled folder access, select Manage Controlled folder access.
- Switch the Controlled folder access setting to Off.
This option apparently blocks any program from creating new files in certain directories.