This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-11
Channels
- # adventofcode (31)
- # announcements (6)
- # babashka (5)
- # beginners (93)
- # calva (15)
- # cider (20)
- # cljs-dev (16)
- # clojure (159)
- # clojure-berlin (1)
- # clojure-dev (5)
- # clojure-europe (9)
- # clojure-italy (9)
- # clojure-losangeles (2)
- # clojure-nl (26)
- # clojure-spec (7)
- # clojure-uk (33)
- # clojurescript (54)
- # clojutre (5)
- # cursive (20)
- # datomic (23)
- # emacs (19)
- # events (1)
- # expound (1)
- # figwheel-main (1)
- # fulcro (104)
- # hyperfiddle (1)
- # jobs (1)
- # luminus (10)
- # malli (59)
- # nrepl (1)
- # off-topic (11)
- # pathom (5)
- # planck (15)
- # reagent (13)
- # reitit (8)
- # rewrite-clj (10)
- # ring-swagger (3)
- # shadow-cljs (129)
- # tools-deps (46)
- # xtdb (14)
- # yada (1)
e.g. here:
$ clojure -Srepro -Sdeps '{:deps {myscript {:git/url "" :sha "89f66ba2101180a98acf88441693840875288ec9"}}}' -Spath
I want only the git dep to be on the classpathbut I'm getting:
src:/Users/borkdude/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar:/Users/borkdude/.gitlibs/libs/myscript/myscript/89f66ba2101180a98acf88441693840875288ec9:/Users/borkdude/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar:/Users/borkdude/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar
I want to use tools.deps to create a classpath and download deps for a clojure interpreter tool I'm writing
Via clj, no (due to the install deps.edn). Via tools.deps, yes.
clj is a Clojure runner
It assumes you’re using Clojure
btw I could see this feature be useful for other environments like self-hosted Clojure / planck, which is already using the clojure
like this
I'll ask in their channel how they solve this "problem" (more of an optimization really)
You can run tools.deps from clj btw - there is a built in alias for it -A:deps
It’s not exactly a 1 liner but the tools are there (really depends precisely on what you want to do)
I'll figure something out. Btw, dirty hack: {:deps {org.clojure/clojure {:local/root "."}}}
really ugly 1-liner:
clj -A:deps -e "(println ((requiring-resolve 'clojure.tools.deps.alpha/make-classpath) ((requiring-resolve 'clojure.tools.deps.alpha/resolve-deps) {:deps {'org.ow2.asm/asm {:mvn/version \"7.2\"}} :mvn/repos @(requiring-resolve 'clojure.tools.deps.alpha.util.maven/standard-repos)} nil) nil nil))"
prints to stdout /Users/alex/.m2/repository/org/ow2/asm/asm/7.2/asm-7.2.jar
asm just used as an example
you could also slurp from deps.edn or whatever (some tools for that stuff in clojure.tools.deps.alpha.reader)
I think I'll just use the existing tools though, the entire tooling is already there, caching and all, it'd be a lot of work and error-prone to replicate this. I'll just skip over some known deps that aren't interesting for the interpreter
The idea is that the interpreter is a drop-in replacement for a program you can otherwise run with normal Clojure (give or take some reader conditionals)
gotcha - to some degree the :classpath-overrides alias option is a good match for this
you could just override the classpath part for org.clojure/clojure to nothing
I guess you'd need to also do clojure's deps though
clj -Sdeps '{:aliases {:bye {:classpath-overrides {org.clojure/clojure "" org.clojure/spec.alpha "" org.clojure/core.specs.alpha ""}}}}' -A:bye -Spath
{:aliases {:babashka {:classpath-overrides {org.clojure/clojure nil
org.clojure/spec.alpha nil
org.clojure/core.specs.alpha nil}}}}
$ clj -C:babashka -Spath
src:::
I should probably be killing the nils in there :)
but yeaeh
committed that fix for whenever I do next release
well, would use str/blank? for that case
imo it's bad form to seq-ize strings with empty? vs using a string-specific predicate
Not that I need it right now, but it is possible to override the tools.deps version for the clojure tool to a git dep on master?
no, not without hacking the script
hacking works fine though, I test stuff that way all the time :)
I guess maybe for this use of -A:deps, you might be able to use :override-deps or :classpath-overrides to make that work
that is, there is no hook to affect the classpath of the jvm run that uses tools.deps.alpha to make the classpath, but you could use the existing alias modifiers to change the classpath of the program you're running if it uses tools.deps.alpha