I have a new MacBook Pro that uses Apple silicon (Mx Pro). 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. To make sure these used when available, it modifies the system variable PATH by prepending /opt/homebrew/bin. In a terminal, echo $PATH returns "/opt/homebrew/bin:/usr/local/sbin:/..." However, in RStudio, the PATH system variable begins with "/usr/local/sbin:/..."
More curiously, are the following outputs
- From the RStudio console, system2(command = "echo", args = "$PATH") returns"/usr/local/sbin:/..."
From the RStudio terminal, echo $PATH returns "/opt/homebrew/bin:/usr/local/sbin:/..."
Rstudio finds its PATH variable from somewhere other than the system environment, and in particular it leaves off /opt/homebrew/bin. This is particularly a problem when compiling packages. For example compiling terra from the GitHub version within RStudio fails but works fine when I run it from R in a terminal.
My question is how can I modify RStudio's PATH environment so it does something like this PATH =paste(" /opt/homebrew/bin", system path)