Loading .env Files
If any of dotenv-load, dotenv-filename, dotenv-path, or dotenv-required
are set, just will try to load environment variables from a file.
If dotenv-path is set, just will look for a file at the given path, which
may be absolute, or relative to the working directory.
If dotenv-filename is set just will look for a file at the given path,
relative to the working directory and each of its ancestors.
If dotenv-filename is not set, but dotenv-load or dotenv-required are
set, just will look for a file named .env, relative to the working directory
and each of its ancestors.
dotenv-filename and dotenv-path and similar, but dotenv-path is only
checked relative to the working directory, whereas dotenv-filename is checked
relative to the working directory and each of its ancestors.
It is not an error if an environment file is not found, unless
dotenv-required is set.
The loaded variables are environment variables, not just variables, and so
must be accessed using $VARIABLE_NAME in recipes and backticks.
For example, if your .env file contains:
# a comment, will be ignored
DATABASE_ADDRESS=localhost:6379
SERVER_PORT=1337
And your justfile contains:
set dotenv-load
serve:
@echo "Starting server with database $DATABASE_ADDRESS on port $SERVER_PORT…"
./server --database $DATABASE_ADDRESS --port $SERVER_PORT
just serve will output:
$ just serve
Starting server with database localhost:6379 on port 1337…
./server --database $DATABASE_ADDRESS --port $SERVER_PORT