Evan Zamir
Evan Zamir

Reputation: 8481

How do I import bash variables in R? (Rstudio server)

Let's say I have environment variables in my bash profile that I want to use in R. How would I call those in? For example:

export MYSQL_USER='bob'
export MYSQL_PWD='secret'

I tried using Sys.getenv("MYSQL_USER"), but it just returns a blank.

Upvotes: 1

Views: 710

Answers (1)

damienfrancois
damienfrancois

Reputation: 59360

If you are running through rstudio server, your Bash startup files are not sourced upon starting your rstudio instance. See this reference to see which file is sourced. On RStudio Server the global startup file is found at R_HOME/etc/Renviron.site by default.

Upvotes: 2

Related Questions