deps-new

yogthos 2024-01-03T18:06:01.443799Z

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?

yogthos 2024-01-03T18:06:10.014889Z

it looks like the template is up https://clojars.org/io.github.kit-clj/deps-template

yogthos 2024-01-03T18:07:04.552759Z

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

yogthos 2024-01-03T18:48:38.904539Z

@seancorfield any tips?

yogthos 2024-01-03T18:50:09.119219Z

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

seancorfield 2024-01-03T20:25:27.444689Z

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.

seancorfield 2024-01-03T20:28:18.597049Z

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

yogthos 2024-01-03T20:29:47.594629Z

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

yogthos 2024-01-03T20:32:09.766429Z

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

seancorfield 2024-01-03T20:35:42.442119Z

(in a meeting, will dig in shortly)

🙌 1
yogthos 2024-01-03T20:36:25.941379Z

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

seancorfield 2024-01-03T21:17:29.647359Z

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?

yogthos 2024-01-03T21:18:13.388319Z

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

yogthos 2024-01-03T21:18:38.181509Z

the lein template explicitly references the deps template as a dependency

seancorfield 2024-01-03T21:20:38.927779Z

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

yogthos 2024-01-03T21:21:23.189839Z

right, and I don't see why

seancorfield 2024-01-03T21:21:23.535059Z

(I was trying the earlier version, which worked)

yogthos 2024-01-03T21:21:52.982289Z

the jar for the new version looks fine to me

seancorfield 2024-01-03T21:21:57.681819Z

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

yogthos 2024-01-03T21:22:26.206969Z

shouldn't it be generated though?

yogthos 2024-01-03T21:22:52.670339Z

here's the build step https://github.com/kit-clj/kit/blob/master/build.clj#L51

yogthos 2024-01-03T21:23:29.645559Z

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>

seancorfield 2024-01-03T21:23:30.777019Z

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

yogthos 2024-01-03T21:25:02.358899Z

so why is this happening?

seancorfield 2024-01-03T21:25:59.564319Z

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.

seancorfield 2024-01-03T21:26:18.599219Z

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

yogthos 2024-01-03T21:26:43.197169Z

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

yogthos 2024-01-03T21:26:54.954479Z

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

yogthos 2024-01-03T21:27:27.993219Z

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

yogthos 2024-01-03T21:27:45.941749Z

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

seancorfield 2024-01-03T21:27:50.426669Z

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

yogthos 2024-01-03T21:27:56.354319Z

because the template pom doesn't contain any dependencies

seancorfield 2024-01-03T21:28:07.937459Z

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>

yogthos 2024-01-03T21:28:14.019039Z

oh I see, let me try switch to using that

seancorfield 2024-01-03T21:28:15.651259Z

So I'm a bit puzzled.

yogthos 2024-01-03T21:28:25.926609Z

right, the jar that gets built seems fine

yogthos 2024-01-03T21:28:56.543109Z

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

seancorfield 2024-01-03T21:34:58.495799Z

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

yogthos 2024-01-03T21:35:07.660749Z

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

yogthos 2024-01-03T21:35:46.028129Z

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

seancorfield 2024-01-03T21:36:26.696649Z

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!

yogthos 2024-01-03T21:36:41.968239Z

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

yogthos 2024-01-03T21:37:16.553219Z

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

seancorfield 2024-01-03T21:37:17.181849Z

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

yogthos 2024-01-03T21:37:26.106449Z

yeah looks that way

yogthos 2024-01-03T21:37:45.494179Z

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

seancorfield 2024-01-03T21:38:15.077359Z

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

seancorfield 2024-01-03T21:39:17.316449Z

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

yogthos 2024-01-03T21:40:19.386699Z

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

yogthos 2024-01-03T21:44:28.940189Z

and thanks again for the help!

seancorfield 2024-01-03T21:44:55.610429Z

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

seancorfield 2024-01-03T21:45:12.494109Z

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

💯 1
yogthos 2024-01-03T21:45:26.783549Z

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

yogthos 2024-01-03T21:45:34.931769Z

it's easy to miss, but tricky to debug

seancorfield 2024-01-03T21:48:42.587189Z

https://github.com/clojure-doc/clojure-doc.github.io/issues/67

🎉 1
yogthos 2024-01-03T21:52:17.279519Z

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

seancorfield 2024-01-03T21:55:45.202619Z

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.

yogthos 2024-01-03T21:57:45.171839Z

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

seancorfield 2024-01-03T21:58:44.837299Z

I would say they are not the same.

seancorfield 2024-01-03T22:00:09.249539Z

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.

yogthos 2024-01-03T22:00:46.799489Z

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

yogthos 2024-01-03T22:00:54.998879Z

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

yogthos 2024-01-03T22:01:06.631299Z

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

seancorfield 2024-01-03T22:01:55.443159Z

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.

yogthos 2024-01-03T22:06:17.356929Z

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