The keytool command fails without the directory existing first. Add mkdir -p before the keytool genkeypair command.