by Devin Walters

Software Developer, Musician, Armchair Philosopher

attaching clojure deps directly to the source file

I thought it would be a neat idea to implant a deps map directly inside of a clojure source file so it could be run without having an associated deps.edn on disk. This is of course possible via -Sdeps, but if you are using all the options, it can get a little long to enter it on the command line.

Here’s a file named foo.clj with implanted deps information:

'{:deps {cheshire {:mvn/version "5.8.0"}}}
(ns foo (:require [cheshire.core :as json]))
(println (json/parse-string "{\"a\": 1}"))

chmod +x foo.clj && ./foo.clj => {a 1}

The script to do this is here:


set -e

if [ $# -eq 0 ]; then
    echo "usage: doclj <file> [args ...]"
    exit 1;



/bin/clj -Sdeps "$(clj --eval '(fnext (read-string (slurp "'"$FILE"'")))')" -i $FILE -- "$@"

Continue reading →