Fork me on GitHub
#tools-deps
<
2021-12-09
>
dvingo02:12:05

I'm not sure if this is the correct place to ask but... I just spent over an hour trying to figure out why I got this:

$ clj
Error building classpath. class clojure.lang.Symbol cannot be cast to class clojure.lang.Keyword (clojure.lang.Symbol and clojure.lang.Keyword are in unnamed module of loader 'app')
java.lang.ClassCastException: class clojure.lang.Symbol cannot be cast to class clojure.lang.Keyword (clojure.lang.Symbol and clojure.lang.Keyword are in unnamed module of loader 'app')
	at clojure.lang.Keyword.compareTo(Keyword.java:114)
	at clojure.lang.Util.compare(Util.java:153)
	at clojure.lang.APersistentVector.compareTo(APersistentVector.java:439)
	at clojure.lang.Util.compare(Util.java:153)
	at clojure.core$compare.invokeStatic(core.clj:842)
	at clojure.core$compare.invoke(core.clj:833)
	at clojure.lang.AFunction.compare(AFunction.java:51)
	at java.base/java.util.TimSort.binarySort(TimSort.java:296)
	at java.base/java.util.TimSort.sort(TimSort.java:239)
	at java.base/java.util.Arrays.sort(Arrays.java:1441)
	at clojure.core$sort.invokeStatic(core.clj:3103)
	at clojure.core$sort.invokeStatic(core.clj:3090)
	at clojure.tools.deps.alpha$sort_paths.invokeStatic(alpha.clj:565)
	at clojure.tools.deps.alpha$flatten_libs.invokeStatic(alpha.clj:573)
	at clojure.tools.deps.alpha$make_classpath_map.invokeStatic(alpha.clj:592)
	at clojure.tools.deps.alpha$calc_basis.invokeStatic(alpha.clj:738)
	at clojure.tools.deps.alpha.script.make_classpath2$run_core.invokeStatic(make_classpath2.clj:128)
	at clojure.tools.deps.alpha.script.make_classpath2$run.invokeStatic(make_classpath2.clj:170)
	at clojure.tools.deps.alpha.script.make_classpath2$_main.invokeStatic(make_classpath2.clj:224)
	at clojure.tools.deps.alpha.script.make_classpath2$_main.doInvoke(make_classpath2.clj:191)
	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)
and was digging through tools.deps sources which led me here: https://github.com/clojure/tools.deps.alpha/blob/a4aa25a54b6bc7bb0b87e7e553276cd5b0463417/src/main/clojure/clojure/tools/deps/alpha.clj#L569 and then found out that one of my my libspecs had a : in front of it... and thus that sort was being invoked with something like:
(sort '[[:com.wsscode/pathom-viz lilactown/helix cljs-bean/cljs-bean] [nubank/workspaces cljsjs/highlight])
So the request would be for some better error/sanity checking when building the classpath map, to confirm the data is valid.

hiredman02:12:52

There are tools that do linting of deps.edn files already

dvingo03:12:36

Thanks, I'm aware of kondo's ability to lint deps files. Personally I experienced performance problems when I used it last (integrating with cursive), but I'll try it again. I would say though, because t.d.a is such an essential tool when working with clojure I think it makes sense to add basic sanity checking to the config map. Imagine someone new to the language who has a single character typo and as a result sees that stacktrace which gives no clue as to how to proceed or where to look. Seems like a great opportunity to improve the user experience of using clojure.

Alex Miller (Clojure team)05:12:19

thanks, we have specs for the deps file but for historical reasons, they're not being used yet, thanks for the bump

🙂 1
jmayaalv13:12:38

hi! is there a way to set the jvm version clojure cli uses? didn’t manage to find anything in the docs.

Alex Miller (Clojure team)13:12:42

It uses whatever Java version you have on the path

Alex Miller (Clojure team)13:12:23

So totally up to you :)

jmayaalv13:12:27

got it! thank you alex!

Kira Howe21:12:21

Can I use a project that uses leiningen as a local dep (i.e. is there some way to tell tools.deps the manifest type is a project.clj file?

Alex Miller (Clojure team)21:12:16

currently, no but there is a pending ticket/patch for this

Kira Howe22:12:46

cool! thanks 🙏

borkdude22:12:12

@kiraemclean A workaround could be to add the deps of that project to your project and then include that project using {:git/url ... :sha ... :deps/manifest :deps}

borkdude22:12:37

or :local/root as you asked

borkdude22:12:18

but since you already have that project locally, you can also use lein pom to write a pom.xml and then tools.deps will understand it without any other changes

👍 2
Kira Howe23:12:12

ah amazing, this is very helpful, thanks 🙂 relatedly.. need to learn better debugging skills for Clojure. I’m trying to debug a weird issue and want to dig around the source of a library but finding it hard with just my editor 😭

rickmoynihan12:12:59

Just give me a shout if you want some hands on help or a pairing session

🙏 1