ENVASSERT(1p)
πΈ envassert(1p) β ok bestie, let's talk environment variables
So this is a manual page for envassert, and yeah it lives in the Perl user-contributed docs corner of your system (the 1p situation, iykyk). It's giving "check your vibes before you commit" but for environment variables. Let's go. π
β¨ NAME β¨
envassert β make sure the environment variables match what you need, or just abort. No half-measures, no "we'll deal with it later." Periodt.
π VERSION π
version 0.015
π¦ SYNOPSIS π¦
envassert [options]
Options, listed for your convenience:
--help
--man
--version
--break-at-first-error, -b
--env-description, -e
--exact, -x
--stdin, -s
π DESCRIPTION π
okay so, envassert checks that your runtime environment β the one defined by environment variables β actually matches what you want. Vibe check, but for env vars.
You can define your required environment in a file. Default file is .envassert but you can use any file. Your file, your rules, bestie.
It is advantageous to use envassert for example when running a container. If you check your environment for missing or wrongly defined environment variables at the beginning of the container run, your container will fail sooner instead of in a later point in execution when the variables are actually needed. Failing fast is the main character move, fr fr. π
π Errors π
There are three kinds of errors:
ENV_ASSERT_MISSING_FROM_ENVIRONMENTβ "Variable<var_name>is missing from environment"ENV_ASSERT_INVALID_CONTENT_IN_VARIABLEβ "Variable<var_name>has invalid content"ENV_ASSERT_MISSING_FROM_DEFINITIONβ "Variable<var_name>is missing from description"- This error will only be reported if you have set the special option
exact. See below. π
- This error will only be reported if you have set the special option
π§ Environment Description Language π§
Environment is described in file .envdesc. Environment description file is a Unix shell compatible file, similar to a .env file. Shell-compatible, so it's not doing anything weird.
π .envdesc Format π
In .envdesc file there is only environment variables, comments or empty rows. Example:
# Required env
## envassert (opts: exact=1)
FILENAME=^[[:word:]]{1,}$
Env var name is followed by a regular expression. The regexp is an extended Perl regular expression without quotation marks. One env var and its descriptive regexp use one row. One row, one job.
A comment begins at the beginning of the row and uses the whole row. It start with # character.
Two comment characters and the word envassert at the beginning of the row mean this is an envassert meta command. You can specify different environment related options with these commands. β¨
Supported options:
exactβ The optionexactmeans that all allowed env variables are described in this file. Any unknown env var causes an error when verifying.
π CLI interface without dependencies π
The envassert command is also available as self contained executable. You can download it and run it as it is without additional installation of CPAN packages. Of course, you still need Perl, but Perl comes with any normal Linux installation. Perl said "I'm already here, girl."
This can be convenient if you want to, for instance, include envassert in a docker container build.
curl -LSs -o envassert https://raw.githubusercontent.com/mikkoi/env-assert/main/envassert.self-contained
chmod +x ./envassert
π NAME π
envassert β Ensure that the environment variables match what you need, or abort. (Yes bestie, it's in here twice. The original said so. We don't question the lore. π)
β¨ OPTIONS β¨
--helpβ Print a brief help message and exits.--manβ Prints the manual page and exits.--versionβ Prints the version and exits.-b,--break-at-first-errorβ Break checking at the first error and report back. Default:false-e,--env-descriptionβ Path to file which has the environment description. Default:.envdesc-x,--exactβ Fail check if environment contains variables not defined in environment description. This option will override the equivalent option in.envdescfile. Default:false-s,--stdinβ Read environment description fromSTDIN, not from a file. Incompatible with option--env-description. Default:false
π₯ EXAMPLES π₯
$ envassert
Environment Assert: ERRORS:
variables:
FIRST_VAR: Variable FIRST_VAR is missing from environment
FOURTH_VAR: Variable FOURTH_VAR is missing from environment
π«Ά Embedded In a Script π«Ά
#!/usr/bin/env sh
# Ensure we have the required environment setup.
envassert <<'EOF'
NUMERIC_VAR=^[[:digit:]]+$
TIME_VAR=^\d{2}:\d{2}:\d{2}$
EOF
echo "${NUMERIC_VAR}: ${TIME_VAR}"
Look at her go. Heredoc queen. π
π DEPENDENCIES π
No external dependencies outside Perl's standard distribution. Zero extra installs, we love a low-maintenance icon.
β SEE ALSO β
Env::Dot is a "sister" to Env::Assert. Read environment variables from a .env file directly into you program. There is also script envdot which can turn .env file's content into environment variables for different shells.
π AUTHOR π
Mikko Koivunalho <mikkoi@cpan.org>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2023 by Mikko Koivunalho.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
And that's the whole thing, bestie β this page came to you from the ENVASSERT(1p) manual, perl v5.40.1, dated 2025-12-21. Stay validated out there, and may all your env vars be present and correctly formatted. πβ¨
π¦ where this page comes from
- ubuntu resolute: env-assert 0.015-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: env-assert 0.015-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms