MyNixOS website logo
Description

Load Environment Variables from '.env'.

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

Project Status: Active - The project has reached a stable, usablestate and is being activelydeveloped. R buildstatus CRAN RStudio mirrordownloads CoverageStatus

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

install.packages("dotenv")

Usage

You can simply put

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

Metadata

Version

1.0.3

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows