Exit to the command line.
cd RetroPie-Setup/
sudo ./retropie-setup.sh
Then select “Source-based installation”
Then select item 61 “ES-Config” and press Enter.
It’ll take about 30 minutes to run. Then you should be able to get past the script errors.