Opening RStudio on Mac using Finder doesn't pick up environment variables

If I open "R" from command line on Mac, it sees my system env variables fine. Also if I use "open -na Rstudio", that works too. But if I open RStudio by clicking the application icon, it doesn't seem to pick up my env variables. How can i make it do this? Normally i prefer to open Mac apps through their icons, not on command line. Thanks.

the easiest solution, in my experience, is to set your environment variables in your .Rprofile instead of using the system. In Mac different settings get set depending on where you start an application. But R will always run your .Rprofile (unless you explicitly tell it not to).

you can set environment variables with something like this in the .Rprofile:

Sys.setenv(MYVARIABLE = 'my_value')
1 Like

Thanks, this is about AWS ID and Secret ID. The are currently set in my .bash_profile for other purposes, I had hoped I wouldn't have to duplicate them in two different files on my system. Perhaps I'll put them in a text file and then find a way to have my .bash_profile load them from that text file, and likewise maybe there's a way do the same in .Rprofile.

Is there a way to pass all environment variables to RStudio and just have RStudio override? The method of .Rprofile seems to have user to know what they need before hand what is need from system environments.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.