Fork me on GitHub

I couldn't find whether this was discussed before, but it feels a bit odd that aliases cannot hint at their preferred call structure and that is a peculiarity the caller has to know about (i.e: -M vs. -X). I suppose this stems from the fact that there's only so much the large bash wrapper can figure out, right? Or let me rephrase: if there was a way for tools to hint at their preferred calling convention, would a clojure cli flag honoring that be considered?

Alex Miller (Clojure team)13:06:37

Not sure I understand what the request is at the end


@U06V097TP The usual solution to this is to use a task manager thing like Makefile, or`bb.edn`


@U06V097TP An alias can contain both :main-opts and :exec-fn so its behavior depends on whether you use -X or -M. Generally tho', looking at the alias in deps.edn tells you which usage it expects: :main-opts implies -M, :exec-fn or :exec-args or :ns-default implies -X. Given my first point, usage could not be inferred however.


If an alias contains :extra-deps and :exec-fn, you can still use it with -M and it will bring in those deps but then expect you to provide main opts somewhere else, either via other aliases in combination or on the command-line.


Similarly, if an alias contains :extra-deps and :main-opts, you can still use it with -X and it will bring in those deps but then expect you to provide exec opts somewhere else, either via other aliases in combination or on the command-line.


For a long time, my dot-clojure deps.edn file had aliases with both :exec-fn and :main-opts so you could invoke certain tools with either -X or -M (and so you got to choose how to provide command-line arguments). And that's another reason why the tool can't decide for you: clojure -[X or M]:some-alias :arg '{:value 42}' -- those arguments will be read as EDN and put into a hash map if you use -X but they'll be treated as strings if you use -M.

Sam Ritchie16:06:27

question - when I use create-basis in to create a basis and pass it to pom, it looks like that command adds org.clojure/clojure to the pom. i THINK I don’t want to do this, but instead let the user specify their Clojure version — so 1. is that correct? and 2. what is the best way to prevent from adding this dep?

Alex Miller (Clojure team)16:06:35

Clojure is defined as a dep in the root deps.edn. If you want to not include the root, you can pass :root nil to create-basis

Alex Miller (Clojure team)16:06:04

Whether you want to do that is hard for me to answer :)

Alex Miller (Clojure team)16:06:24

You do need something to declare a dep on Clojure or you can't run Clojure programs

Sam Ritchie17:06:14

@U064X3EF3 I had been browsing and seen many library that didn’t declare the dep at all, which made me think folks have settled on providing clj and cljs scoped as "provided"

Sam Ritchie17:06:55

which is eminently reasonable (that is how it should be done ALWAYS for cljs I’d say). but an explicit Clojure dep makes sense too obviously, at the lowest version you can support

Alex Miller (Clojure team)17:06:25

I think not specifying is a reasonable choice for libraries

Alex Miller (Clojure team)17:06:05

but I understand the many reasons libs do specify one

Alex Miller (Clojure team)17:06:23

the important thing is that ultimately some app is going to make the choice anyways

Sam Ritchie16:06:11

etaoin for example does not declare org.clojure/clojure as a dependency, but I don’t see an obvious spot where this is excluded:


Warning @sritchie09 that build.clj is pretty new and has not been used for a real release yet! As far as I understand it, I think the best practice is for a library to explicitly depend on the minimum Clojure version required for the lib.


(If that’s what you are wondering about?)


An app writer will typically specify clojure as a dep overriding any library clojure deps.

Sam Ritchie17:06:22

@lee okay that makes sense! and in that case that is easy to manage


I find it especially nice in deps.edn because dep resolution seems simple, clean and intuitive to me when compared to lein deps resolution (which maybe I really just haven’t taken the time to understand).