Windows Shell Local Runner - Cleaning up file based variables ERROR: Job failed: exit status 1

I have a problem with my GitLab jobs failing right away with:

Cleaning up file based variables
ERROR: Job failed: exit status 1

This appears to be happening before any of my script runs. It happens right after:

Getting source from Git repository
Fetching changes with git depth set to 50…
Reinitialized existing Git repository in C:/GitLab-Runner/builds/fssw7qQs/0/…etc…
Checking out 1fb5944a as SHUB-479-GitLab-Build…
Removing SomePath/SomeFile
…lots of times - cleaning out repo
Cleaning up file based variables
ERROR: Job failed: exit status 1

If I manually empty my repo in the build location before running my pipeline, the first job succeeds, but the second fails, apparently because the repo isn’t empty anymore and it needs re-emptied for a fresh checkout.

Any thoughts on what might be going on here?

The new default for GitLab to use PowerShell Core aka “pwsh” as a default shell starting from GitLab 14 caused the error for me. If you use shell = "powershell" in your config.toml everything should work fine again.