This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-05-18
Channels
- # announcements (3)
- # babashka (13)
- # beginners (28)
- # biff (12)
- # clj-yaml (13)
- # clojure (13)
- # clojure-europe (2)
- # clojure-norway (11)
- # clr (1)
- # core-typed (3)
- # datahike (1)
- # datascript (5)
- # datomic (12)
- # fulcro (8)
- # graalvm (8)
- # hyperfiddle (20)
- # missionary (8)
- # off-topic (20)
- # pedestal (1)
- # releases (2)
- # shadow-cljs (12)
- # yamlscript (7)
I had a load dependency cycle and I changed one require from :as
to :as-alias
and that seems to have fixed it, except when I run tests via tools build, e.g. clj -T:build ci
which uses io.github.seancorfield/build-clj
run-tests
function. That one still reports a cycle. How is this possible? Is it running some old version of clojure?
if I run just clj
and require the namespace in REPL offered, it gets loaded successfully
Take build-clj
out of the equation and write a simple :test
alias using Cognitect's test-runner
.
I think you'll still get the error because the test runner loads all namespaces (and I suspect the cycle is still there, somewhere else in your code).
And please stop using build-clj
. It was a bad idea, and I regret creating it.
The namespaces in the cycle are clearly stated, so I don’t think there’s a cause elsewhere. I can run tests fine if I just use clj cmd and load them in the repl. It’s when I try to run test via the tools alias that the cycle magically appears. The compiler message is not factually correct. The namespaces are not in a cycle due to as-alias use.
I guess I have to create a simple reproduction.
I would have expected an old version of Clojure to complain about :as-alias
but apparently it doesn't -- it's just treated as :as
instead 👀 TIL!
(~/clojure)-(!2008)-> clj -A:1.8
Clojure 1.8.0
user=> (ns foo (:require [foo.bar :as-alias bar]))
FileNotFoundException Could not locate foo/bar__init.class or foo/bar.clj on classpath. clojure.lang.RT.load (RT.java:456)
foo=>
Sat May 18 11:22:06
(~/clojure)-(!2008)-> clj -A:1.9
Clojure 1.9.0
user=> (ns foo (:require [foo.bar :as-alias bar]))
FileNotFoundException Could not locate foo/bar__init.class or foo/bar.clj on classpath. clojure.lang.RT.load (RT.java:463)
foo=>
Sat May 18 11:22:14
(~/clojure)-(!2009)-> clj -A:1.10
Clojure 1.10.3
user=> (ns foo (:require [foo.bar :as-alias bar]))
Execution error (FileNotFoundException) at foo/eval138$loading (REPL:1).
Could not locate foo/bar__init.class, foo/bar.clj or foo/bar.cljc on classpath.
foo=>
Sat May 18 11:22:26
(~/clojure)-(!2010)-> clj -A:1.11
Clojure 1.11.3
user=> (ns foo (:require [foo.bar :as-alias bar]))
nil
foo=>
So it is possible that somehow clojure -T:build run-tests
is picking up a different version of Clojure than you expect but it should be using the deps from :test
-- which is what you'd get if you ran clojure -X:test
directly (or clojure -M:test
depending on how you have it set up)...Interesting. Well I don’t have Clojure declared in my deps as a dependency. So I would assume that the version is used that is used by cli tools themselves. Especially considering that if I just use clj command to create repl then a fairly new version is started. I guess there might be some sort of interaction with tools alias. I do recall that with -T switch you’re starting with an empty deps list.
build-clj
uses clojure.tools.build.api/java-command
and process
to run tests in a subprocess, using the default basis for the project with the alias :test
.
Do you have a user-level deps.edn
? Does it specify a Clojure version? And what does clojure -version
show?
clojure -version
Clojure CLI version 1.11.2.1446
I have user level deps.edn but it doesn’t specify clojure version in any of the aliases