I am using a MacBook Pro with Apple silicon. To take advantage of the programs that can use this natively, homebrew creates a new directory (/opt/homebrew) that is functionally the same as /usr/local except that it holds the packages that are native to R rewritten for Apple silicon.
Thus, in Terminal in Mac OS X, echo $PATH correctly returns
Note the missing "/opt/homebrew/bin:/opt/homebrew/sbin".
The same issue occurs if I open a new terminal window in RStudio IDE (Note: different than Terminal in Mac OS X) and type echo $PATH (the homebrew directories are missing.)
How do I permanently modify the PATH that RStudio uses to add "/opt/homebrew/bin:/opt/homebrew/sbin"?
Thank you!
(Please don't refer me to random StackOverflow articles—I have been through them and none of those options work. The RStudio application apparently does not look to the .bash_profile or the .zshrc profile when setting PATH. I even tried editing the Info.plist in RStudio.app directory to set the PATH there, but that did not work either.)
I'm having exactly same issue, went through the entire internet, no solutions so far. It's quite inconvenient since R packages need to be compiled on M1 - but this will throw an error if a package requires other tools installed via homebrew (e.g. cmake or libpng). So far I've resorted to launching rstudio from terminal ("open -na rstudio") which makes it inherit $PATH from zsh.
After rebooting, RStudio now uses same $PATH as my zsh. As a side note, turns out I didn't need to compile most of the packages, most of my issues stemmed from the fact that I used Homebrew-compiled version (brew install r) which is incompatible with CRAN binaries..
After reinstalling R with brew install --cask r I can use binaries.
Apologies for this, this does appear to be a bug on RStudio Desktop for Mac, and we are actively working on a fix but do not have resolution yet. I suggest to follow the linked Github issue above, and keep an eye out for subsequent RStudio releases for a long-term fix. However, in the meantime, a temporary workaround is to create or modify the ~/.Renviron file, setting PATH="/opt/homebrew/bin:/opt/homebrew/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/Little Snitch.app/Contents/Components:/opt/X11/bin:/Applications/RStudio.app/Contents/MacOS/postback" or whatever the desired value of your PATH variable should be. The PATH should show correctly if you run R directly from your Terminal, and so you can run Sys.getenv("PATH") in R directly (not RStudio) to get the desired value of the PATH to paste into your ~/.Renviron file. We are working to resolve this issue.
Another temporary workaround that should work in the meantime -- if you double click the RStudio app icon to open the application, it will load with the incorrect PATH variable. If however, you launch RStudio from your Terminal (open /Applications/RStudio.app) the PATH variable should be correct when running Sys.getenv("PATH") in your RStudio console. Again, you can save that PATH to your ~/.Renviron file if you don't want to have to remember to launch from the terminal each time. We hope this workaround helps until a fix is released.