Bear spray is very effective. Making your presence known is an important part of preventing encounters, surprising a bear is generally not a good thing. It's why people try to make periodic/loud noise when in bear country.
Efficacy of the spray is covered here:
https://www.distinctlymontana.com/...-vs-gun-which-better
Efficacy of the spray is covered here:
https://www.distinctlymontana.com/...-vs-gun-which-better