Can't deploy with Ruby 3.1.2

I’m having the exact same issue: Netlify App

As far as I can tell, my .ruby-version file is correct: https://github.com/gesteves/gateway/blob/redesign/.ruby-version

For what it’s worth, if I hit “clear cache and retry deploy”, it works correctly, so it seems it’s related to caching somehow (unfortunately this makes deploys take longer and it’s eating into my build minutes, so it’s not a tenable long-term solution).