How does RStudio set the PATH during startup?

I am having some problems building rgl in RStudio on my Mac M3, because the PATH that it sees during the build includes /usr/local/bin before /opt/R/arm64/bin. I can't seem to spot how RStudio determines the initial PATH setting. Can I control it?