mine use ruby3 to install metasploit so no need to install ruby2
if you want ruby2 install gushmazuko repo :
https://github.com/gushmazuko/metasploit_in_termux
command and code :
First update and upgrade
apt update
apt upgrade
Install git and git clone this repo then run scritp
apt install git
git clone https://github.com/Craglitch/metasploit-in-termux-craglitch-version-/
cd metasploit-in-termux-craglitch-version-
bash metasploit.sh
just use this command without "./" :
msfconsole
msfvenom
and boom boom boom your metasploit is install you can delete metasploit-in-termux-craglitch-version
Ruby3 is not fully support yet ok