Where does the PATH variable come from in sys.getenv()?

Hello, I was having some issues running a system call and they were resolved when I manually edited the PATH variable from R console using Sys.setenv(). However, I noticed that the Sys.getenv("PATH") returns something different than what the terminal returns when I use "echo $PATH". Where does the R console get the PATH variable from? I'm running on a mac.

1 Like

If you are starting RStudio from your macOS Dock or Spotlight, then it gets them from the system launcher. Setting an environment variable for a program launched in this way is possible but surprisingly tricky.

Fortunately, unless PATH is critical to R startup, you can have R set it for you when you start an R session instead of having macOS do it. You do this by adding it to an .Renviron file. More here:

https://rstats.wtf/r-startup.html

1 Like

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