Fork me on GitHub
#tools-deps
<
2022-03-18
>
imre18:03:44

https://github.com/polyfy/polylith/blob/5292e8ab1bea3ff84b08c7f2142dbe7f1349a3f3/deps.edn#L78-L81 that uses the keys :deps and :paths in one of its aliases as opposed to their (extra/replace) counterparts. I failed to find any documentation wrt the usage of these keys in an alias. Does anyone know where I could get more info on why someone would want to use them there as opposed to :extra-*?

Alex Miller (Clojure team)18:03:24

They are synonyms for :replace-deps and :replace-paths - notably they replace the project paths and deps rather than add to

seancorfield18:03:18

@U08BJGV6E see https://clojure.org/guides/tools.build for examples where you have :deps in aliases.

imre19:03:12

Thank you both, I see I was looking in the wrong place. However, I do have a question wrt synonyms @U064X3EF3 - I don't see the phrases replace or synonym at https://clojure.org/guides/tools_build - so my question is, are these synonyms (as in all contexts) or only appear to behave like synonyms due how https://clojure.org/reference/deps_and_cli#_aliased_tool_execution works?

imre19:03:03

What is the intended behavior of these keys when the alias in question is used not in a tool execution context but to start a repl together with other aliases, like clj -A:build:dev:test?

Alex Miller (Clojure team)19:03:03

They are synonyms in all alias contexts

Alex Miller (Clojure team)19:03:23

No difference in tool / non-tool

Alex Miller (Clojure team)19:03:37

Well I guess the big difference is that -T removes the project paths and deps regardless

imre20:03:01

Oh I see, thank you. So is my understanding correct that if I want to use an alias both as a tool with only the deps/paths specified in the alias: clojure -T:my-alias and as an additional alias (with the additonal paths/deps) for a repl: clojure -A:dev:test:my-alias then I should just continue using :extra-paths/deps? And a side question just so I understand properly: if deps/replace-deps and paths/extra-paths are synonyms in every context, then why do both exist? Is using one recommended over using the other in some contexts and why?

seancorfield20:03:47

Historical reasons and, now, backward compatibility.

seancorfield20:03:50

I'm afk right now (on vacation in England) but I thought deps/paths behaved in a context-sensitive manner. If have to double check the source 😁

imre21:03:15

I guess I should be able to throw something together next week to test my assumptions in case there isn't some official-like documentation that explains this. Enjoy your holiday!

practicalli-johnny10:03:16

I found the synonyms confusing myself. I prefer using the specific keys so it's very clear what the alias does

Alex Miller (Clojure team)14:03:54

in the context of running a tool with -T, the project :deps and :paths are removed, so it may feel more natural in that case to use :deps and :paths rather than :replace-deps and :replace-paths. But in the context of -X where :deps and :paths are not removed, it can be helpful to use :replace-deps and :replace-paths to make that clear. so, that's why both synonyms exist

1
🙏 1
imre14:03:20

Thank you Alex. Is my understanding correct that there in the -T:tool context one could also use :extra-* without any observable difference at runtime (due to the removal you mentioned)?

imre14:03:40

If the answer to that is yes, then would it be safe to assume that if an alias is to be used both as a -T tool and an extra alias for my repl, it would be better to stick with :extra-* if I don't want it to affect project deps/paths when in the repl?

imre15:03:27

Brilliant, thank you!

Carlo23:03:12

When I follow this guide (the uberjar case) https://clojure.org/guides/tools_build, after writing the suggested content in build.clj and deps.edn, I get this interaction:

$ clj -X:build clean
Namespace could not be loaded: build
What am I doing wrong?

Alex Miller (Clojure team)00:03:55

Should be -T not -X ?

🙌 1
Carlo01:03:52

Thank you 🙈