Fork me on GitHub
#tools-deps
<
2023-02-13
>
Sam Ritchie12:02:53

Question… I think I’ve seen here that :git/tag for dependencies will NOT work without an associated :git/sha. however, this command seems to work fine:

clojure -Ttools install io.github.seancorfield/deps-new '{:git/tag "v0.4.13"}' :as new
while this one fails:
clojure -Sdeps '{:deps {io.github.mentat-collective/clerk-utils {:git/tag "v0.3.0"}}}' \
-Tnew create \
:template clerk-utils/custom \
:name myusername/my-notebook-project
with
Error building classpath. Library io.github.mentat-collective/clerk-utils has coord with missing sha
is there something about -Ttools install that allows you to forgo the :git/sha?

borkdude12:02:28

install just is more lenient here. there is also install-latest

Sam Ritchie12:02:11

got it, makes sense after digging through the code

Sam Ritchie12:02:30

I wish there were some easy way to have github inject the current SHA into a README.md

borkdude12:02:35

tools like #C03KCV7TM6F allow you to add a dependency by tag:

neil add dep io.github.mentat-collective/clerk-utils --git/tag v0.3.0

❤️ 2
borkdude12:02:43

and then it adds the sha for you

borkdude12:02:50

without providing the tag it picks the last tagged release

borkdude12:02:19

for README: I sometimes work with templates that I re-generate, but the downside of this is that I regularly receive PRs that update the generated README instead of the template :)

👍 2
seancorfield18:02:09

In deps.edn, the SHA acts as a check on the tag -- to make sure they match and you're not picking up some random version because someone moved the tag (tags are mutable in git, SHAs are not). tools install is kind of odd that way so I assume the thinking is that picking up some random version of an installed "dev tool" is less important/less risky than your production code picking up some random version? @U064X3EF3?

Alex Miller (Clojure team)18:02:44

correct, this was an intentional choice to require less here

1
rafaeldelboni23:02:18

Hi is there a way to use tools.deps to load a dependency programmatically, quite similar to https://insideclojure.org/2018/05/04/add-lib/, but not using the repl? I want to calculate the git hash and then add an dependency in runtime, quite similar of what borkdude does in neil + deps-new, but only using clojure tools.deps.

Alex Miller (Clojure team)23:02:08

The add-lib stuff is a function

rafaeldelboni23:02:44

Yes, but I saw it uses DynamicClassLoader's addURL and this only works on repl right?

seancorfield00:02:01

It depends on the context. You can "easily" set up that context yourself programmatically.

seancorfield00:02:52

My :add-libs alias includes the code via -e but you could just add this into your code: https://github.com/seancorfield/dot-clojure/blob/develop/deps.edn#L128

rafaeldelboni00:02:25

Interesting thanks!