Description Usage Arguments Details Examples
View source: R/dotenv-package.r
Load variables defined in the given file, as environment variables.
1 | load_dot_env(file = ".env")
|
file |
The name of the file to use. |
The file is parsed line by line, and line is expected to have one of the following formats:
1 2 3 4 5 6 | VARIABLE=value
VARIABLE2="quoted value"
VARIABLE3='another quoted variable'
# Comment line
export EXPORTED="exported variable"
export EXPORTED2=another
|
In more details:
A leading export
is ignored, to keep the file
compatible with Unix shells.
No whitespace is allowed right before or after the equal sign, again, to promote compatilibity with Unix shells.
No multi-line variables are supported currently. The file is strictly parsed line by line.
Unlike for Unix shells, unquoted values are not terminated by whitespace.
Comments start with #
, without any leading
whitespace. You cannot mix variable definitions and
comments in the same line.
Empty lines (containing whitespace only) are ignored.
It is suggested to keep the file in a form that is parsed the
same way with dotenv
and bash
(or other shells).
1 2 3 4 5 6 7 8 9 10 11 12 | # Remove, if it exists
Sys.unsetenv("dotenvexamplefoo")
Sys.getenv("dotenvexamplefoo")
# Load from a file
tmp <- tempfile()
cat("dotenvexamplefoo=bar\n", file = tmp)
load_dot_env(tmp)
Sys.getenv("dotenvexamplefoo")
# Clean up
unlink(tmp)
|
[1] ""
[1] "bar"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.