Tiny utility library for loading .env files & getting/setting environment variables.
Currently tested with: SBCL, Allegro, ECL, CLISP
NOTE: Corrupt .env files will generate an error when being loaded. Make sure your .env file is in the format:
key1=value
key2=value
Calling load-env
loads the environment from the specified .env file.
(dotenv:load-env (merge-pathnames "./path/.env"))
=> t
The value of a variable can be read by calling get-env
with the name of the variable.
(dotenv:get-env "SOME_VAR")
=> "value" or nil
If you wish, you can provide a default value that is returned if the variable you are trying to read is not set.
(dotenv:get-env "SOME_NONEXISTING_VAR" "default-value")
=> "default-value"
Setting a variable overwrites any existing value
(dotenv:set-env "SOME_VAR" "some_value")
=> t
The package is not yet available through Quicklisp. (Issue)
Manual installation steps:
cd ~/quicklisp/local-projects/
git clone https://github.com/ollelauribostrom/cl-dotenv.git
(ql:quickload :cl-dotenv)
All contributions are very much welcome. Please get familiar with the contributing guide.
make install
: Install the packages cl-dotenv and cl-dotenv-test locally using Roswellmake test
: Run the tests using Provemake coverage
: Run the tests and generate a coverage reportmake sbcl
: Start SBCL and load cl-dotenv
- Olle Lauri Boström (ollebostr@gmail.com)
Licensed under the MIT License.