How to depend on tools.build?

I’m reading the tools.build guide, and in the end of the “Source library jar build” it shows how the deps.edn file should look like:

{:paths ["src"]
 :aliases
 {:build {:deps {io.github.clojure/tools.build {:tag "TAG" :sha "SHA"}}
          :ns-default build}}}

And then the commands to use what we have done so far:

clj -T:build clean
clj -T:build jar

Ok. Clojure now tells me about T being not supported anymore so I have to use X. Cool.
There is another warning about deps and using `replace-deps. But that is just a warning :smiley:

For finding the values for tag and sha I follow the values in the README of tools.build Github page.

It tells me that:

Latest release:
deps.edn dependency information:
io.github.clojure/tools.build {:git/tag "v0.1.6" :git/sha "5636e61"}

So I’m trying to make this work but each time I’m getting an error.

These are my iterations of my deps.edn followed by the error when I try to execute:

clojure -X:build clean

1

I’m writing the values of the coordinates I found in the project README in the template suggested by the guide.

deps.edn:

{:paths ["src"]
 :aliases
 {:build {:replace-deps {io.github.clojure/tools.build {tag "v0.1.6" :sha "5636e61"}}
          :ns-default build}}}

Error:

Error building classpath. No coordinate type found for library io.github.clojure/tools.build in coordinate {tag "v0.1.6", :sha "5636e61"}

2

This time I’m writing the coordinate as suggested by the README of the project (which include the git namespace) on top of the template of the guide.

deps.edn:

{:paths ["src"]
 :aliases
 {:build {:replace-deps {io.github.clojure/tools.build {:git/tag "v0.1.6" :git/sha "5636e61"}}
          :ns-default build}}}

Error:

Error building classpath. Library io.github.clojure/tools.build has missing :sha in coordinate.

3

Because the previous error says “missing :sha”, I’m just adding it.

deps.edn:

{:paths ["src"]
 :aliases
 {:build {:replace-deps {io.github.clojure/tools.build {:git/tag "v0.1.6" :git/sha "5636e61" :sha "5636e61"}}
          :ns-default build}}}

Error:

Error building classpath. Prefix sha not supported, use full sha for io.github.clojure/tools.build

4

Ok, so I can’t use prefix sha. I need the full one. I had to go figure out which one is it in Github…
Didn’t find it. What?

Ok… Let me see what is the actual SHA of the tag v0.1.6 in the repository. It is 1e7c019730dc6f9e38793170c8801c5950516b60. So why the README says something different?.

Nevermind, I’ll try with that:

deps.edn:

{:paths ["src"]
 :aliases
 {:build {:replace-deps {io.github.clojure/tools.build {:git/tag "v0.1.6" :git/sha "1cd59e6" :sha "1e7c019730dc6f9e38793170c8801c5950516b60"}}
          :ns-default build}}}

Error:

Error building classpath. 
java.lang.NullPointerException
	at java.base/java.util.regex.Matcher.getTextLength(Matcher.java:1770)
	at java.base/java.util.regex.Matcher.reset(Matcher.java:416)
	at java.base/java.util.regex.Matcher.<init>(Matcher.java:253)
	at java.base/java.util.regex.Pattern.matcher(Pattern.java:1133)
	at java.base/java.util.regex.Pattern.split(Pattern.java:1261)
	at java.base/java.util.regex.Pattern.split(Pattern.java:1334)
	at clojure.string$split.invokeStatic(string.clj:224)
	at clojure.string$split.invoke(string.clj:219)
	at clojure.tools.gitlibs.impl$clean_url.invokeStatic(impl.clj:52)
	at clojure.tools.gitlibs.impl$clean_url.invoke(impl.clj:48)
	at clojure.tools.gitlibs.impl$git_dir.invokeStatic(impl.clj:59)
	at clojure.tools.gitlibs.impl$git_dir.invoke(impl.clj:57)
	at clojure.tools.gitlibs.impl$ensure_git_dir.invokeStatic(impl.clj:83)
	at clojure.tools.gitlibs.impl$ensure_git_dir.invoke(impl.clj:80)
	at clojure.tools.gitlibs$procure.invokeStatic(gitlibs.clj:67)
	at clojure.tools.gitlibs$procure.invoke(gitlibs.clj:61)
	at clojure.tools.deps.alpha.extensions.git$eval1356$fn__1358.invoke(git.clj:42)
	at clojure.lang.MultiFn.invoke(MultiFn.java:239)
	at clojure.tools.deps.alpha$expand_deps.invokeStatic(alpha.clj:422)
	at clojure.tools.deps.alpha$expand_deps.invoke(alpha.clj:390)
	at clojure.tools.deps.alpha$resolve_deps.invokeStatic(alpha.clj:495)
	at clojure.tools.deps.alpha$resolve_deps.invoke(alpha.clj:475)
	at clojure.tools.deps.alpha$calc_basis.invokeStatic(alpha.clj:655)
	at clojure.tools.deps.alpha$calc_basis.invoke(alpha.clj:629)
	at clojure.tools.deps.alpha.script.make_classpath2$run_core.invokeStatic(make_classpath2.clj:91)
	at clojure.tools.deps.alpha.script.make_classpath2$run_core.invoke(make_classpath2.clj:57)
	at clojure.tools.deps.alpha.script.make_classpath2$run.invokeStatic(make_classpath2.clj:119)
	at clojure.tools.deps.alpha.script.make_classpath2$run.invoke(make_classpath2.clj:113)
	at clojure.tools.deps.alpha.script.make_classpath2$_main.invokeStatic(make_classpath2.clj:169)
	at clojure.tools.deps.alpha.script.make_classpath2$_main.doInvoke(make_classpath2.clj:140)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.lang.Var.applyTo(Var.java:705)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.main$main_opt.invokeStatic(main.clj:514)
	at clojure.main$main_opt.invoke(main.clj:510)
	at clojure.main$main.invokeStatic(main.clj:664)
	at clojure.main$main.doInvoke(main.clj:616)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.lang.Var.applyTo(Var.java:705)
	at clojure.main.main(main.java:40)

Ok, I’m tiered for today. Too much time on this. At least I see another kind of error. I must have a typo in my code or something…

Anyways…

Do you see any mistake I have made in my steps?
Is the doc misleading or I missed something else?

I’m trying to learn here and have that super simple piece of code working.

Thank you!

3 Likes

You need a prerelease version of the Clojure CLI for this to work. 1.10.3.929 is the latest prerelease available at the moment.

The blog post about the release of tools.build lists all of the things that changed with the prerelease: Clojure - Source Libs and Builds and it notes that you have to use at least 1.10.3.905 for all of this but there have already been several bug fixes and updates since then: Releases · clojure/brew-install (github.com)

1 Like

Yes, that was it.

Thank you!