-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathREADME.Rmd
81 lines (63 loc) · 2.5 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
output: github_document
---
```{r, setup, echo = FALSE, message = FALSE}
knitr::opts_chunk$set(
comment = "##",
error = TRUE,
tidy = FALSE,
fig.width = 8,
fig.height = 8)
```
<!-- badges: start -->
[](https://www.repostatus.org/#active)
[](https://github.com/gaborcsardi/dotenv/actions)
[](https://www.r-pkg.org/pkg/dotenv)
[](https://codecov.io/github/gaborcsardi/dotenv?branch=master)
<!-- badges: end -->
# 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.
## Installation
```{r eval = FALSE}
install.packages("dotenv")
```
## Usage
You can simply put
```{r eval = FALSE}
library(dotenv)
```
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:
```
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).