Fork me on GitHub

Is there a way to get the dependency tree of a project as data? I'm trying to figure out the paths that lead to a specific transitive dependency and clojure -Stree | grep <dependency name> -B 8 unfortunately includes a lot of garbage from other branches, which I'm not interested in. It's quite possible that I'm focusing on the wrong thing, so happy to consider a different approach as well! edit: The real "why" is that there's a known vulnerability for one of my transitive dependencies, so I'm trying to figure out which of my direct dependencies will be affected if I upgrade it (override it with a newer version)! 🙂

Alex Miller (Clojure team)13:06:06

You can get data from clj -X:deps tree :format :edn

❤️ 2

Oh sweet, thanks! Is this documented? On my phone right now but I swear I looked in the first and couldn't find it. 😅


what’s the way to invoke -X with an environment variable? clj -X :filename $OUT_FILE style?


With any additional escaping, those args pass through read-string


yeah. but i need to enable expansion in the shell and then ensure it’s readable to clojure and i’ve forgotten the exact sequence of double and single quotes necessary to thread that needle



$ bb -e "*command-line-args*" $OUTFILE
$ bb -e "*command-line-args*" \"$OUTFILE\"
$ bb -e "(edn/read-string (first *command-line-args*))" \"$OUTFILE\"

🙏 1

clojure -X :filename '"'$OUTFILE'"'


(I use that in several invocations -- also with '"'$(...)'"')