This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-03
Channels
- # aleph (2)
- # announcements (6)
- # babashka (6)
- # beginners (106)
- # biff (8)
- # clara (24)
- # clj-kondo (10)
- # clj-otel (4)
- # cljdoc (2)
- # clojure (54)
- # clojure-conj (3)
- # clojure-europe (85)
- # clojure-norway (54)
- # clojure-uk (3)
- # clojurescript (27)
- # community-development (2)
- # data-science (1)
- # datahike (2)
- # datomic (11)
- # deps-new (67)
- # emacs (4)
- # graalvm (15)
- # hyperfiddle (11)
- # introduce-yourself (1)
- # lsp (6)
- # malli (30)
- # midje (4)
- # nrepl (13)
- # off-topic (86)
- # polylith (7)
- # releases (2)
- # sql (10)
could somebody help me out figure out why I'm getting Could not load template, require of
after publishing the latest template for Kit?
it looks like the template is up https://clojars.org/io.github.kit-clj/deps-template
but running clojure -Tclj-new create :template io.github.kit-clj :name yourname/guestbook
gives an error that template can't be loaded?
@U04V70XH6 any tips?
I see both jars in my .m2 repo locally, and as far as I can tell everything looks fine there, the only change I made in my build was to add a pom.xml template with a license https://github.com/kit-clj/kit/commit/8ff7b5a21ed48ec3c42374e0261c24455a3a622a
If you run it with :verbose 3
(per the suggested output I see from that command), you should see this failure:
Caused by: java.io.FileNotFoundException: Could not locate io/github/kit_clj/deps_template/helpers__init.class, io/github/kit_clj/deps_template/helpers.clj or io/github/kit_clj/deps_template/helpers.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
Trying that in a REPL certainly seems to work tho'...
it's this file here https://github.com/kit-clj/kit/blob/master/libs/deps-template/src/io/github/kit_clj/deps_template/helpers.clj
It seems that
is trying to load that other ns so maybe it isn't on the classpath for your Leiningen template when it runs?
That version doesn't work tho':
(~/clojure)-(!2007)-> clj -Sdeps '{:deps {io.github.kit-clj/deps-template {:mvn/version "0.1.51"}}}'
Downloading: io/github/kit-clj/deps-template/0.1.51/deps-template-0.1.51.pom from clojars
Downloading: io/github/kit-clj/deps-template/0.1.51/deps-template-0.1.51.jar from clojars
Clojure 1.12.0-alpha5
user=> (require 'io.github.kit-clj.deps-template.helpers)
Execution error (FileNotFoundException) at io.github.kit-clj.deps-template.helpers/eval140$loading (helpers.clj:1).
Could not locate selmer/parser__init.class, selmer/parser.clj or selmer/parser.cljc on classpath.
user=>
(I was trying the earlier version, which worked)
Oh, I bet you didn't update the pom.xml
with dependencies
here's the build step https://github.com/kit-clj/kit/blob/master/build.clj#L51
the template pom has
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi="" xsi:schemaLocation=" ">
<licenses>
<license>
<name>MIT License</name>
<url> </url>
</license>
</licenses>
</project>
(~/clojure)-(!2009)-> clj -Sdeps '{:deps {io.github.kit-clj/deps-template {:mvn/version "0.1.51"}}}' -Stree
org.clojure/clojure 1.12.0-alpha5
. org.clojure/spec.alpha 0.3.218
. org.clojure/core.specs.alpha 0.2.62
io.github.kit-clj/deps-template 0.1.51
Wed Jan 03 13:22:22
(~/clojure)-(!2010)-> clj -Sdeps '{:deps {io.github.kit-clj/deps-template {:mvn/version "0.1.47"}}}' -Stree
org.clojure/clojure 1.12.0-alpha5
. org.clojure/spec.alpha 0.3.218
. org.clojure/core.specs.alpha 0.2.62
io.github.kit-clj/deps-template 0.1.47
. selmer/selmer 1.12.50
. babashka/fs 0.1.6
You've got a lot going on in that build.clj
that I don't have time to debug right now but I would recommend not putting a template pom.xml
at the top-level of the repo -- it'll mess up tooling that tries to analyze your project.
(see the http://clojure-doc.org tools.build cookbook for information about that)
Your tools.build is too old for :pom-data
. Needs to be 0.9.6
I looked in the 0.1.51 JAR and the pom has
<dependencies>
<dependency>
<groupId>selmer</groupId>
<artifactId>selmer</artifactId>
<version>1.12.50</version>
</dependency>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
<version>1.11.1</version>
</dependency>
<dependency>
<groupId>babashka</groupId>
<artifactId>fs</artifactId>
<version>0.1.6</version>
</dependency>
</dependencies>
So I'm a bit puzzled.
The only difference I can see in the 0.1.51 and 0.1.47 pom.xml
files is that 0.1.47 has <modelVersion>4.0.0</modelVersion>
and <packaging>jar</packaging>
but 0.1.51 does not. The Maven spec says the former is required (but I think the latter is a default).
Ah, if modelVersion
and packaging
are not in the src-pom, tools.deps does not add them -- but if you do not provide a src-pom, it does add them!
thanks for the help debugging, I always forget to think about updating the dependencies before going down a rabbit hole 🙂
ah ok that makes sense, so I guess with the providing a template pom file, just have to add more defaults to it
I bet if you use pom-data
instead, you get modelVersion
and packaging
I could've saved myself a lot of time if I just thought of bumping up tools.build version
You don't have any scm
stuff in there either -- so http://cljdoc.org fails to import anything: https://cljdoc.org/d/io.github.kit-clj/deps-template/0.1.51
https://clojure-doc.org/articles/cookbooks/cli_build_projects/#the-generated-pomxml-file shows all the stuff you want in there for pom-data
-- in the pom-template
function
Glad we got to the bottom of it. That was a weird one.
indeed, it might actually be worth adding an explicit section on the cookbook to contrast using pom.xml vs pom-data in terms of defaults
now I'm wondering if the behavior in tools.build is intentional or accidental, it would be nice if both ways worked consistently
The docs are pretty clear about what it replaces or adds if you provide a src-pom
but I think they are less clear about what it creates by default.
right, and the general intent with both src-pom
and pom-data
appears to be the same, so adding consistent set of defaults in both cases would be a lot less error prone
I would say they are not the same.
src-pom
is intended to provide a fully-fleshed pom.xml
that tools.deps
only updates/adds specific items to. pom-data
is purely additive, so you are telling tools.deps
to create its pom.xml
as usual but also add the top-level data you provide.
There's a bunch of stuff I used to have in my template pom.xml
file -- licenses, developers, scm, etc. It was a full pom.xml
except for dependencies and the version.