dotenv v1.0.1


Monthly downloads



by Gabor Csardi

Load Environment Variables from '.env'

Load configuration from a '.env' file, that is in the current working directory, into environment variables.


Linux Build Status Windows build status CRAN RStudio mirror downloads

dotenv — Load environment variables from .env

This package loads the variables defined in the .env file in the current working directory (as reported by getwd()), and sets them as environment variables.

This happens automatically when the dotenv package is loaded, so the typical use-case is to just put a library(dotenv) call at the beginning of your R script.

Alternatively a dotenv::load_dot_env() call can be used to load variables from arbitrary files.




You can simply put


at the beginning of your script, to load the environment variables defined in .env in the current working directory.

File format

The .env file is parsed line by line, and line is expected to have one of the following formats:

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).

Functions in dotenv

Name Description
dotenv-package Load configuration parameters from .env into environment variables
load_dot_env Load environment variables from the specified file
No Results!

Last month downloads


License MIT + file LICENSE
LazyData true
NeedsCompilation no
Packaged 2016-04-07 13:48:15 UTC; gaborcsardi
Repository CRAN
Date/Publication 2016-04-07 16:11:05
Contributors Gabor Csardi

Include our badge in your README