dotenv
1 Usage Examples
2 API
dotenv-load!
dotenv-read
7.7

dotenv

Royall Spence <royall@royall.us>

 (require dotenv) package: dotenv

A library that allows for reading .env files instead of environment variables

1 Usage Examples

To load from .env to override your program’s environment variables, just use dotenv-load!

To load multiple files, pass one or more path-string? arguments
(require dotenv)
(dotenv-load! "raccoon.env" "possum.env")

The legacy calling convention of passing a list of filenames still works

NOTE: This calling convention is deprecated; use rest arguments, instead.

(require dotenv)
(dotenv-load! '("raccoon.env" "possum.env"))

To return a new environment-variables? set instead of updating current-environment-variables, use dotenv-read
(require dotenv)
(define other-env (dotenv-read "raccoon.env" "possum.env"))

The legacy calling convention for dotenv-read also still works

NOTE: This calling convention is deprecated; use rest arguments, instead.

(require dotenv)
(define other-env (dotenv-read '("raccoon.env" "possum.env")))

2 API

procedure

(dotenv-load! filename ...)  (listof boolean?)

  filename : path-string?
Update current-environment-variables using the values parsed from all the files given as arguments. Updates are done in order, so later definitions override earlier ones. If no arguments are passed, the file .env from the current-directory will be loaded.

Return value represents success or failure of setting each var; every element should be #t. Raises exception on failure.

Changed in version 1.2 of package dotenv: Can now use path-string? rest arguments.

Changed in version 1.2 of package dotenv: Calling with a list argument is deprecated.

procedure

(dotenv-read filename ...)  environment-variables?

  filename : path-string?
Otherwise identical to dotenv-load!, except that instead of returning a (listof boolean?), a newly created environment-variables? set is returned. current-environment-variables is not modified by calling this procedure.

Raises exception on failure.

Added in version 1.1 of package dotenv.

Changed in version 1.2 of package dotenv: Can now use path-string? rest arguments.

Changed in version 1.2 of package dotenv: Calling with a list argument is deprecated.

Changed in version 1.2 of package dotenv: Now behaves like dotenv-load! and attempts to read .env when no arguments are given.