It's a snippet of old code but it should work OK.
It works for me on a PC - I don't have a suitable MAC to hand...
Nothing different in v2022 as far as I can see...

What exactly are you trying to do, are there any Ruby Console messages before the failure ?