This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-25
Channels
- # babashka (9)
- # beginners (56)
- # calva (18)
- # clj-kondo (2)
- # clojars (2)
- # clojure (46)
- # clojure-boston (1)
- # clojure-europe (4)
- # clojurescript (10)
- # css (1)
- # data-science (2)
- # emacs (10)
- # girouette (1)
- # helix (10)
- # jobs-discuss (4)
- # malli (2)
- # off-topic (28)
- # polylith (5)
- # re-frame (4)
- # reitit (8)
- # releases (6)
- # rewrite-clj (1)
- # sci (44)
- # sql (10)
- # tools-deps (31)
How do I add an additional alias to clj -X:deps tree
. The alias dev as extra-deps, but they don’t show up in the tree when I clj -X:deps:dev tree
Use -Stree
instead of -X:deps tree
if you do -X:foo:bar:baz
for example, the deps from aliases foo and bar are included on the classpath. also those of baz, but you will only eXecute a function from the baz alias.
Although :exec-fn
is "last one wins", :exec-args
are merged across all the aliases you specify. That can be a very useful trick to use aliases to modify the behavior of an exec function.
So if each of :foo
, :bar
, and :baz
have both :exec-fn
and :exec-args
, then the function that gets invoked will be :baz
's :exec-fn
but with a merged hash map of the :exec-args
from all three aliases.
No. For a brief while you could specify multiple functions tho' but that went away.
clojure -X:foo:bar:baz my.first/func another/func third/func
-- was that only in a prerelease? Dunno. I'm always using one of the latest prereleases so I can't remember.
I think it'll come back at some point but there were ambiguities in terms of argument parsing...
In general when you write :foo:bar:baz
it means you invoke :baz
(exec, main, tool) but with additional deps from aliases foo and bar
The -X
behavior with multiple aliases is not documented. The behavior for :main-opts
(and thus -A
/`-M`) is documented, as it is for :paths
and several other things.
Search this page https://clojure.org/reference/deps_and_cli for multiple
to see the other documented behavior.
There's definitely a lot of "assumed knowledge" in the deps.edn
/CLI docs, unfortunately. I think partly because it has changed a lot over time and partly because a lot of the early users have always been in this channel providing feedback, even before features got implemented, so some of those discussions just never made it into the docs...
Several of the (older) sections on that reference page have bulleted lists with the keys they relate to and a bullet that says "If multiple alias maps with these keys are activated..." but the -X
stuff is introduced in a different way near the top of the page and then the argument parsing is described in detail at the bottom of the page, but there's no simple bulleted list of its keys and behavior.
(and now that I read it, I see concatentating
is misspelled five time on that page)
I've never noticed that before and I've read that page so many times...
I think adding a Function execution section to the overall Execution section, between Main execution and Prepare for execution would be a good start. It could list the four keys that affect function execution (`:exec-fn`, :exec-args
, :ns-default
, and :ns-aliases
) and the "If multiple alias maps with these keys are activated..." bullet.
I think that's the only example in the docs tho'...
Easy to miss, two thirds down that page.
Probably, since that would be the first "mention" of multiple aliases assuming someone reads the entire guide first then then entire reference manual...
How I start my REPL:
SOCKET_REPL_PORT=5000 clojure -Sforce -M:rebel:reflect:jedi-time:reveal:j14:classes:everything:dev:test:build:runner:dev/repl
👀No, aliases can't be amalgams of other aliases (a feature lots of people have requested).
:everything:dev:test:build:runner
all comes from our work project deps.edn
and the other aliases from my dot-clojure deps.edn
(in the repo on GitHub). Just FYI.
Yeah, I've been putting off some chores I should go and do (it's just too hot here).