The bayes_R2 function can be called on any generalized linear model (stan_glm), even those with group-specific parameters (stan_glmer). For the particular function stan_lm, the R^2 is a primitive parameter whose posterior distribution is being estimated, whereas bayes_R2 is essentially a generated quantity rather than a primitive parameter. Either way, they are referring to the same concept and should have the same distribution theoretically.
If you find bayes_R2 useful and want to report it in your work, I suggest you to try loo_R2 too, which tends to suffer less from potential overfitting. See https://avehtari.github.io/bayes_R2/bayes_R2.html for more info.
Could you try running again bayes_R2 and type traceback() immediately after the error? I’d like to see where exactly this allocation is being attempted.
That is all you need. The bayes_R2 is no better of an estimate and loo_R2 tends to differ only with small datasets. You might print yourself a second decimal place by doing print(fit, digits = 2).