LinuxCommandLibrary

dotenvx

Load environment variables from .env files

TLDR

Run a command with environment variables from a .env file

$ dotenvx run -- [command]
copy

Run a command with environment variables from a specific .env file
$ dotenvx run -f [path/to/file.env] -- [command]
copy

Set an environment variable with encryption
$ dotenvx set [key] [value]
copy

Set an environment variable without encryption
$ dotenvx set [key] [value] --plain
copy

Return environment variables defined in a .env file
$ dotenvx get
copy

Return the value of an environment variable defined in a .env file
$ dotenvx get [key]
copy

Return all environment variables from .env files and OS
$ dotenvx get --all
copy

SYNOPSIS

dotenvx [OPTIONS] <COMMAND> [ARGS]
Commands: run, print, vault, help, version

PARAMETERS

-e, --env-file <ENV_FILE>...
    Set one or more environment files to load (default: .env)

-b, --blockenv
    Block inheritance of process.env from parent process

--arch <ARCH>
    Target architecture (e.g., amd64, arm64; default: x64)

--os <OS>
    Target OS (linux, darwin, windows; default: current)

--dotenvx
    Run dotenvx itself with loaded env vars

-h, --help
    Print help information

-V, --version
    Print version information

--
    Separator to pass options to the target command

DESCRIPTION

dotenvx is a high-performance CLI tool for loading environment variables from .env files and running commands with them loaded. Written in Rust, it's up to 1000x faster than traditional Node.js-based dotenv tools. Key features include support for multiple .env files, encrypted secrets via .env.vault, blocking parent environment variables, cross-platform binaries (Linux, macOS, Windows), and no runtime dependencies like Node.js.

Primary use cases: development workflows, CI/CD pipelines, and scripting where secure, fast env loading is needed. It decrypts secrets locally using public keys, ensuring security without exposing them. Run commands directly or use subcommands like print to output vars and vault for secret management.

CAVEATS

Requires downloading platform-specific binary; secrets need DOTENV_PUBLIC_KEY for decryption. Not installed by default on Linux.

EXAMPLE USAGE

dotenvx run -- npm start
dotenvx print DATABASE_URL
dotenvx vault new

INSTALLATION (LINUX)

curl -Ls https://dotenvx.com/install.sh | sh
or wget binary from GitHub releases (github.com/dotenvx/dotenvx/releases)

HISTORY

Created by Guillermo Rauch (Vercel) in 2023 as a Rust rewrite of dotenv CLI tools for speed and security. First release v0.1.0; rapidly adopted for its performance gains over JS alternatives.

SEE ALSO

env(1), direnv(1), bash(1)

Copied to clipboard