A Clojure library for managing environment variable configuration
Stephen Starkey, ACC 4f98dbc644 Updated project documentation 18 hours ago
bin Updated project documentation 18 hours ago
docs Updated project documentation 18 hours ago
spec/defenv More robust displays 2 months ago
src/defenv More robust displays 2 months ago
.env Sort the vars in the usage string. 1 year ago
.gitignore Port from fossil 1 year ago
LICENSE First version 1 year ago
README.md Removed useless documentation 18 hours ago
defenv.css Generated environment variable documentation 1 year ago
project.clj Updated docs. Changed project website. 18 hours ago



A Clojure library designed to make working with environment variables easier.


You’ll need Java 8 and Leiningen.


Say you want to define a binding in a namespace that is filled in by the value specified in an environment variable. Here’s the very simplest way to do it:

(require '[defenv.core :refer [defenv]])

(defenv system-path "PATH")

Then, if you run @system-path you will see the value of that environment variable.

The project documentation contains much more example usage.

Also, you could try running DEFENV_TESTING=bob lein usage

Questions I imagined you might ask

Why does `defenv` make delayed bindings?

Well, the project contains a bit of other magic. If you don’t make a binding to a variable optional, an exception will be thrown when it is dereferenced if it isn’t set. We don’t want these exceptions to be thrown during compile time. Therefore, they must be delayed.

Why can't I load property files and declare multiple
environments in my `project.clj` and stuff?

This library was designed for https://12factor.net/ apps


Copyright © 2019 Stephen Starkey

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.