Fork me on GitHub
#deps-new
<
2024-01-03
>
yogthos18:01:01

could somebody help me out figure out why I'm getting Could not load template, require of .github.kit-clj failed with: Syntax error macroexpanding at (leiningen/new/io/github/kit_clj/options/helpers.clj:1:1) after publishing the latest template for Kit?

yogthos18:01:04

but running clojure -Tclj-new create :template io.github.kit-clj :name yourname/guestbook gives an error that template can't be loaded?

yogthos18:01:09

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

seancorfield20:01:27

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.

seancorfield20:01:18

Trying that in a REPL certainly seems to work tho'...

yogthos20:01:47

yeah I saw the trace there, but I'm not sure why it's not finding it

yogthos20:01:09

and I see the file in the jar in the m2 repo locally

seancorfield20:01:42

(in a meeting, will dig in shortly)

🙌 1
yogthos20:01:25

thanks, much appreciated, I got kind of stumped on this

seancorfield21:01:29

It seems that .github.kit_clj$eval4064$loading__6789__auto____4065.invoke (kit_clj.clj:1) is trying to load that other ns so maybe it isn't on the classpath for your Leiningen template when it runs?

yogthos21:01:13

I haven't changed anything in the template though, and this used to work

yogthos21:01:38

the lein template explicitly references the deps template as a dependency

seancorfield21:01:38

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=>

yogthos21:01:23

right, and I don't see why

seancorfield21:01:23

(I was trying the earlier version, which worked)

yogthos21:01:52

the jar for the new version looks fine to me

seancorfield21:01:57

Oh, I bet you didn't update the pom.xml with dependencies

yogthos21:01:26

shouldn't it be generated though?

yogthos21:01:29

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>

seancorfield21:01:30

(~/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

yogthos21:01:02

so why is this happening?

seancorfield21:01:59

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.

seancorfield21:01:18

(see the http://clojure-doc.org tools.build cookbook for information about that)

yogthos21:01:43

I was actually tried to use :pom-data at first, but that seemed to have no effect

yogthos21:01:54

I'll try moving the pom out of the root folder see what happens

yogthos21:01:27

although the pom for each library does get generated in its own folder

yogthos21:01:45

this still doesn't make sense to me to be honest

seancorfield21:01:50

Your tools.build is too old for :pom-data. Needs to be 0.9.6

yogthos21:01:56

because the template pom doesn't contain any dependencies

seancorfield21:01:07

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>

yogthos21:01:14

oh I see, let me try switch to using that

seancorfield21:01:15

So I'm a bit puzzled.

yogthos21:01:25

right, the jar that gets built seems fine

yogthos21:01:56

but yeah let me try bump up tools.build, that might be an issue with it being so old

seancorfield21:01:58

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).

yogthos21:01:07

ok that worked, I bumped up to 0.9.6 and switched to using pom-data

yogthos21:01:46

and maybe that trips up some check in the pom parser?

seancorfield21:01:26

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!

yogthos21:01:41

thanks for the help debugging, I always forget to think about updating the dependencies before going down a rabbit hole 🙂

yogthos21:01:16

ah ok that makes sense, so I guess with the providing a template pom file, just have to add more defaults to it

seancorfield21:01:17

I bet if you use pom-data instead, you get modelVersion and packaging

yogthos21:01:26

yeah looks that way

yogthos21:01:45

I could've saved myself a lot of time if I just thought of bumping up tools.build version

seancorfield21:01:15

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

seancorfield21:01:17

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

yogthos21:01:19

ah yeah that's handy, I think pom-data makes more sense in my case

yogthos21:01:28

and thanks again for the help!

seancorfield21:01:55

Glad we got to the bottom of it. That was a weird one.

seancorfield21:01:12

Esp. that there was no error from omitting modelVersion...

💯 1
yogthos21:01:26

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

yogthos21:01:34

it's easy to miss, but tricky to debug

yogthos21:01:17

now I'm wondering if the behavior in tools.build is intentional or accidental, it would be nice if both ways worked consistently

seancorfield21:01:45

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.

yogthos21:01:45

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

seancorfield21:01:44

I would say they are not the same.

seancorfield22:01:09

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.

yogthos22:01:46

yeah I guess it's where the process starts is the key difference

yogthos22:01:54

with one you're working off a template and injecting into it

yogthos22:01:06

and with the other you synthesize the pom and add stuff to it after

seancorfield22:01:55

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.

yogthos22:01:17

now I have a bit better understanding of what's happening with the poms 🙂