Can't install rstan on macbook pro M1 core

Hi, I’m using Macbook Pro M1 core to run brms on Rstudio. I have trouble making rstan to work.
Here’s the error message when I try to install rstan:

ld: framework not found CoreFoundation
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [] Error 1
ERROR: compilation failed for package ‘rstan’

I’m a new user of MBP M1 core. I found some relevant posts here but still couldn’t fix it. Any help is appreciated! Thanks!

Can you try making sure that the Developer Tools are installed?

Open a terminal and run:

xcode-select --install 

Then follow the prompts to install, and restart R and try again?

Thanks! Here’s what I got:
xcode-select: error: command line tools are already installed, use “Software Update” in System Settings to install updates

And there’s nothing to update in the software update.

Try running xcode and see if the 't wants you to sign/agree with its license. In the past, I remember sometimes updating xcode and then would work because xcode components only became usable after agreeing to its license

Thank you. I’ll try it and report back here.