$‘\r‘: command not found

The reason for the error is the newline character. Just use the tool to process the script file

sudo apt install dos2unix
dos2unix build.sh

Read More: