This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (9)
- # bangalore-clj (1)
- # beginners (164)
- # calva (7)
- # clj-kondo (12)
- # cljs-dev (5)
- # cljsrn (7)
- # clojure (100)
- # clojure-spec (5)
- # clojure-sweden (2)
- # clojure-uk (4)
- # clojurescript (9)
- # conjure (22)
- # datomic (53)
- # fulcro (62)
- # graalvm (27)
- # helix (10)
- # joker (6)
- # malli (1)
- # mount (4)
- # nrepl (3)
- # off-topic (8)
- # quil (1)
- # releases (1)
- # sci (42)
- # shadow-cljs (1)
- # testing (7)
- # tools-deps (26)
- # vim (24)
If A depends on B, and my project depends on A and B but doesn't really care about the version of B as long as it's compatible with A, how should I specify this dependency on B in
Or should I just omit the dependency on B from
I would figure out what version of B your chosen version of A depends on and explicitly specify that in
deps.edn -- and add a comment about the version selection reason. Assuming you mean that your project has an explicit dependency on B.
That was exactly my thought initially. But now that I've given it some thought - wouldn't it be more practical to just omit it altogether?
If A starts to depend on a different version of B, I should be unaffected, and I won't need to change anything.
If A drops the dependency, the code will just not run because there's an explicit
And specifying B in my
deps.edn seems like just giving myself more work when I update my dependencies.
If A changes the version of B it depends, it also changes its own version -- so unless you are changing the version of A you depend on, you wouldn't be affected 🙂
That's my point: if you choose to depend on a newer version of A, you should also verify the compatibility of the newer version of B that it now depends on as well. Having an explicit dependency on B lets you force the earlier version of B if you need that.
If A stops depending on B, that also means a new version of A and you could decide to stay with the old version or move to the new version -- and because you have an explicit dependency on B, you code won't break (at least, not because A's transitive dependency on B went away).
I really don't like relying on transitive dependencies. I much prefer to have all my dependencies listed explicitly. I've learned that over the years after a decade of Clojure in production 🙂
Hmm, I think I didn't give enough context. I definitely agree with your reasoning about the generic case of relying on a transitive dependency. But in my particular case, the code should either break completely if B is changed/removed, or it should continue working just as I expected it to. So the compatibility with my project is not a concern. At the same time, if I manage to forget to update B after updating A, I may introduce some incompatibilities between A and B that are hard to test.
To be more concrete - I'm just using
ring.util.mime-type/ext-mime-type function without having an explicit dependency on
Of course even such a dead simple function can potentially be broken with an update. But I consider it so improbable that it's not worth taking into account. Akin to how I don't expect
clojure.core/map to suddenly start giving me different results.
I need only
ring.util.mime-type/ext-mime-type from B, which I consider stable in a sense that any changes around it either break the app startup or don't affect the app at all.
Ah, OK. If that is the only Ring namespace you're touching then maybe I would agree and just depend on Yada. It still feels a bit sketchy to me. We depend on Ring and we don't use that var -- we have our own MIME type structures (because we want a specific set of supported values, rather than a generic list).
I wish I would have a specific set. :)
Yeah, I can see how it can feel sketchy. I'm still not sure about the way I work with my dependencies at all right now, given that there's also CLJS and a build process that involves shadow-cljs. Maybe this all could be made nice and simple with aliases. An unrelated to the rest of the thread question - aliases cannot be grouped together under a new alias, right? So I will probably have to write a script to call
It's why at work we have a
build shell script that wraps the
clojure script so we can have "higher-level" aliases.
Right, I've seen this pattern before. Sometimes even with
-Sdeps, to avoid cluttering the main
deps.edn I guess or to make the script more portable.
build script serves two purposes: to allow us to run a series of
clojure commands from a single invocation, and to provide various shorthands for common combinations of aliases (our aliases tend to be very granular). But we're all Clojure / backend. I suspect if we were managing ClojureScript as well, we'd be even more reliant on our wrapper script!
I'm looking forward to
tools.build -- I suspect it will help simplify our tool chain quite a bit.
I don't think I've heard of it and I can't find anything that seems relevant. Is there an announcement or something like that?
Alex mentioned it in an Inside Clojure blog post and has mentioned it several times here.