Welcome! Please see the About page for a little more info on how this works.

0 votes
in tools.deps.alpha by
recategorized by

Originally asked at https://clojurians.slack.com/archives/C6QH853H8/p1643624068729959

It appears -X:deps gets tricked by a user.clj on the path that requires a namespace that is on the project classpath but not on the classpath that -X:deps itself uses.

Is this expected? Is there any better way to handle this than adding something like -Sdeps '{:aliases {:no-paths {:replace-paths []}}}' -A:no-paths?


; # enviroment
; clojure -Srepro -version
Clojure CLI version
; # deps & source
; echo '{:paths ["src"] :deps{org.clojure/java.classpath {:mvn/version "1.0.0"}}}' > deps.edn
; mkdir src && echo '(ns user (:require clojure.java.classpath))' > src/user.clj
; # launch repl
; clj -Srepro
Clojure 1.10.3
user=> (find-ns 'clojure.java.classpath)
#object[clojure.lang.Namespace 0x21325036 "clojure.java.classpath"]

; # check deps
; clojure -Sforce -Srepro -X:deps list :license :none
Exception in thread "main" Syntax error compiling at (user.clj:1:1).
	at clojure.lang.Compiler.load(Compiler.java:7652)
	at clojure.lang.RT.loadResourceScript(RT.java:381)
	at clojure.lang.RT.loadResourceScript(RT.java:368)
	at clojure.lang.RT.maybeLoadResourceScript(RT.java:364)
	at clojure.lang.RT.doInit(RT.java:486)
	at clojure.lang.RT.init(RT.java:467)
	at clojure.main.main(main.java:38)
Caused by: java.io.FileNotFoundException: Could not locate clojure/java/classpath__init.class, clojure/java/classpath.clj or clojure/java/classpath.cljc on classpath.
	at clojure.lang.RT.load(RT.java:462)
	at clojure.lang.RT.load(RT.java:424)
	at clojure.core$load$fn__6856.invoke(core.clj:6115)
	at clojure.core$load.invokeStatic(core.clj:6114)
	at clojure.core$load.doInvoke(core.clj:6098)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5897)
	at clojure.core$load_one.invoke(core.clj:5892)
	at clojure.core$load_lib$fn__6796.invoke(core.clj:5937)
	at clojure.core$load_lib.invokeStatic(core.clj:5936)
	at clojure.core$load_lib.doInvoke(core.clj:5917)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$load_libs.invokeStatic(core.clj:5974)
	at clojure.core$load_libs.doInvoke(core.clj:5958)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$require.invokeStatic(core.clj:5996)
	at clojure.core$require.doInvoke(core.clj:5996)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at user$eval138$loading__6737__auto____139.invoke(user.clj:1)
	at user$eval138.invokeStatic(user.clj:1)
	at user$eval138.invoke(user.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7181)
	at clojure.lang.Compiler.eval(Compiler.java:7170)
	at clojure.lang.Compiler.load(Compiler.java:7640)
	... 6 more
; # check deps with workaround
; clojure -Sdeps '{:aliases {:no-paths {:replace-paths []}}}' -A:no-paths -Sforce -Srepro -X:deps list :license :none
org.clojure/clojure 1.10.3
org.clojure/core.specs.alpha 0.2.56
org.clojure/java.classpath 1.0.0
org.clojure/spec.alpha 0.2.194

1 Answer

+1 vote
selected by
Best answer

Currently, the :deps alias does not do :replace-paths [], but it should and I've filed https://clojure.atlassian.net/browse/TDEPS-216 to fix that.

As a workaround, you can use -T:deps instead (this does :replace-paths ["."] so it's not exactly what you need, but will serve the purpose of removing the src dir from the classpath at least. Alternately, you could redefine the :deps alias.

Thank you Alex. Reading your explanation, I cannot help but think again about https://ask.clojure.org/index.php/9947/could-replace-deps-imply-replace-paths-by-default
Yes, we did consider that and decided not to do that.
Fair enough, thanks for the response.