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 [command] [options]

PARAMETERS

dotenvx run
    Executes a command with the environment variables loaded from the `.env` file. All subsequent arguments are passed to the run command.

dotenvx encrypt
    Encrypts the `.env` file using a specified key or password.

dotenvx decrypt
    Decrypts the `.env` file using a specified key or password.

dotenvx share
    Shares the encrypted `.env` file with other team members or environments.

dotenvx fetch
    Fetches environment variables from a remote source (e.g., a cloud provider).

dotenvx edit
    Edits the `.env` in a secure editor, offering more enhanced options.

dotenvx --version
    Displays the version of dotenvx

dotenvx --help
    Displays help information for dotenvx

DESCRIPTION

dotenvx is a command-line tool designed to simplify the management and sharing of environment variables across different environments (development, staging, production). It extends the functionality of standard `.env` files by offering features like encryption, secrets management, and integration with various cloud providers. The tool allows users to load `.env` files, encrypt sensitive information, and securely share them with team members or deploy them to different environments.

dotenvx focuses on enhancing security and streamlining the process of handling environment variables, which are crucial for configuring applications without hardcoding sensitive data into the codebase. It addresses common challenges related to managing `.env` files, especially in collaborative and production environments, by providing a more robust and controlled approach. It offers features to store and retrieve secrets, making it a useful for projects that require security and separation of configuration. It allows the injection of environment variables into command executions.

CAVEATS

dotenvx relies on proper key management for encryption and decryption. Losing the key or password will render the encrypted `.env` file unusable. Ensure secure storage and handling of keys.

SECURITY CONSIDERATIONS

Security is paramount when using dotenvx.
Always use strong keys/passwords for encryption. Avoid committing encrypted `.env` files to version control without proper access controls. Consider using environment variables provided by your hosting platform for sensitive production secrets.
Carefully evaluate the security implications of sharing encrypted `.env` files and ensure proper access controls are in place.

WORKFLOW INTEGRATION

dotenvx can be integrated into your development workflow using tools like Git hooks or CI/CD pipelines. This allows for automated encryption and decryption of `.env` files during deployment.

HISTORY

dotenvx is a relatively recent tool designed to address the shortcomings of traditional `.env` file management. It emerged as a solution to the challenges of securely storing and sharing environment variables, especially in collaborative development environments and production deployments. Its development reflects the growing need for robust secrets management and configuration management practices in modern software development.

SEE ALSO

env(1), export(1)

Copied to clipboard