Broken ruby 3.1.0 installation on Xcode 14.2.x, on macOS 13.2 (Ventura)

The installation of ruby 3.1.0 is broken on Xcode 14.2.x, on macOS 13.2 (Ventura). gem script from ruby 3.1.0 contains incorrect path resulting in error

Failed to check if cocoapods 1.12.1 installed, error: /Users/Vagrant/.asdf/lib/commands/command-exec.bash: /Users/Vagrant/.asdf/installs/ruby/3.1.0/bin/gem: /Users/vagrant/ruby31/bin/ruby: bad interpreter: No such file or directory
/Users/Vagrant/.asdf/lib/commands/command-exec.bash: line 28: /Users/Vagrant/.asdf/installs/ruby/3.1.0/bin/gem: Undefined error: 0: error: exit status 1

Path in gem from 3.1.0

vagrant@vm-osx-ventura-g2-m1 ~ % cd /Users/vagrant/ruby31/bin
cd: no such file or directory: /Users/vagrant/ruby31/bin

For comparison version 3.1.4 uses correct path


and 3.1.3