I haven't tested on Windows yet, but I will try to find some time to do so.
The first thing would be to check if this .Renviron file is read at all, e.g. if you define a variable `MYPATH='aaa'` can you see it from inside RStudio, or is only `PATH` overwritten?
Other environment variables can be set normally. It appears that only PATH
is overwritten, as described in the GitHub issue I linked to earlier.
I would also check that RStudio is loading the right version of R (e.g. sometimes after installing R4.3.2 RStudio is still loading R4.3.1). That's particularly meaningful if you are using a .Renviron in R_HOME/etc, not if it's in your `~`.
I am using RStudio Version 2023.09.1+494 (2023.09.1+494) on Apple silicon macOS 13.5.2, which loads R v4.3.2. Looks ok to me.
I would also check for a project-specific file. If you create a new project, does RStudio still not take into account your .Renviron?
There is no project, nor a project-specific file. This happens with no project open, and the wd set to "~" (by default).
I can tell that the .Renviron
and .Rprofile
are read - other effects are persistent, including your suggestion of a custom MYPATH
environment variable. Also (as described in my comment on the GitHub issue), If I add this line to the end of ~/.Rprofile
:
cat(Sys.getenv("PATH"), "\n")
it shows the expected modified PATH in the console output at the start of a session:
/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin
But once the session starts, the same command (Sys.getenv("PATH")
) shows a completely different output, without any of the changes applied by .Renviron
or .Rprofile
, as far as the PATH
environment variable is concerned. So it looks very much like RStudio is overwriting PATH
with something else, after loading and running .Renviron
and .Rprofile
. I know that GUI applications inherit their environment variables (such as PATH
) differently than shells in macOS, but the same thing does not happen in the base R GUI, and I'm wondering what R Studio is doing differently (and why?).
Thanks,
Jonathan