thheller / shadow-cljs

ClojureScript compilation made easy
https://github.com/thheller/shadow-cljs
Eclipse Public License 1.0
2.23k stars 173 forks source link

`Caused by: java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.tools.analyzer.utils/update-vals` when trying to import a dependency via git #1176

Closed kovasap closed 3 months ago

kovasap commented 3 months ago

When running clj -M:shadow-cljs watch app for my repo at https://github.com/kovasap/biomarker-correlator, I get the following error. Strangely, I can eliminate this error when using the :mvn/version of the oz library at https://github.com/kovasap/biomarker-correlator/blob/f2bfa1c4cdbe53580a2e51973d6d85bef4ed1415/deps.edn#L4. Use of the :git/sha version leads to this failure. I'd like to use the :git/sha version because it contains a fix necessary for my code to work.

The really strange part is that ALL of the :git/sha versions of oz I've tried from https://github.com/metasoarous/oz/commits/master/ run into the same issue, even those for which the code should be the same as the :mvn/version like https://github.com/metasoarous/oz/commit/4602ece17fe62bd058d15200881d65f1da06f8f8. This makes me think there is some issue with the way either shadow-cljs or something lower down the stack manages git dependencies. Has anyone here seen this issue before, or think I should file it in another location?

 clj -M:shadow-cljs watch app

Checking out: https://github.com/metasoarous/oz.git at 5e728a9c14612da2a1b9b871acbd9a4229ca71a2
Downloading: com/taoensso/sente/1.13.1/sente-1.13.1.pom from clojars
Downloading: com/taoensso/sente/1.13.1/sente-1.13.1.jar from clojars
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer.utils, being replaced by: #'clojure.tools.analyzer.utils/update-vals
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer.passes, being replaced by: #'clojure.tools.analyzer.utils/update-vals
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer.passes.uniquify, being replaced by: #'clojure.tools.analyzer.utils/update-vals
Exception in thread "main" Syntax error macroexpanding clojure.core.async/go at (clojure/core/async.clj:512:6).
    at clojure.lang.Compiler.macroexpand1(Compiler.java:7027)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:7110)
    at clojure.lang.Compiler.analyze(Compiler.java:6806)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:7112)
    at clojure.lang.Compiler.analyze(Compiler.java:6806)
    at clojure.lang.Compiler.analyze(Compiler.java:6762)
    at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:6135)
    at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5479)
    at clojure.lang.Compiler$FnExpr.parse(Compiler.java:4041)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:7122)
    at clojure.lang.Compiler.analyze(Compiler.java:6806)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:7112)
    at clojure.lang.Compiler.analyze(Compiler.java:6806)
    at clojure.lang.Compiler.access$300(Compiler.java:38)
    at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:596)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:7124)
    at clojure.lang.Compiler.analyze(Compiler.java:6806)
    at clojure.lang.Compiler.analyze(Compiler.java:6762)
    at clojure.lang.Compiler.eval(Compiler.java:7198)
    at clojure.lang.Compiler.load(Compiler.java:7653)
    at clojure.lang.RT.loadResourceScript(RT.java:381)
    at clojure.lang.RT.loadResourceScript(RT.java:372)
    at clojure.lang.RT.load(RT.java:459)
    at clojure.lang.RT.load(RT.java:424)
    at clojure.core$load$fn__6908.invoke(core.clj:6161)
    at clojure.core$load.invokeStatic(core.clj:6160)
    at clojure.core$load.doInvoke(core.clj:6144)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invokeStatic(core.clj:5933)
    at clojure.core$load_one.invoke(core.clj:5928)
    at clojure.core$load_lib$fn__6850.invoke(core.clj:5975)
    at clojure.core$load_lib.invokeStatic(core.clj:5974)
    at clojure.core$load_lib.doInvoke(core.clj:5953)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invokeStatic(core.clj:669)
    at clojure.core$load_libs.invokeStatic(core.clj:6016)
    at clojure.core$load_libs.doInvoke(core.clj:6000)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:669)
    at clojure.core$require.invokeStatic(core.clj:6038)
    at clojure.core$require.doInvoke(core.clj:6038)
    at clojure.lang.RestFn.invoke(RestFn.java:3204)
    at shadow.cljs.devtools.api$eval144$loading__6789__auto____145.invoke(api.clj:1)
    at shadow.cljs.devtools.api$eval144.invokeStatic(api.clj:1)
    at shadow.cljs.devtools.api$eval144.invoke(api.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:7194)
    at clojure.lang.Compiler.eval(Compiler.java:7183)
    at clojure.lang.Compiler.load(Compiler.java:7653)
    at clojure.lang.RT.loadResourceScript(RT.java:381)
    at clojure.lang.RT.loadResourceScript(RT.java:372)
    at clojure.lang.RT.load(RT.java:459)
    at clojure.lang.RT.load(RT.java:424)
    at clojure.core$load$fn__6908.invoke(core.clj:6161)
    at clojure.core$load.invokeStatic(core.clj:6160)
    at clojure.core$load.doInvoke(core.clj:6144)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invokeStatic(core.clj:5933)
    at clojure.core$load_one.invoke(core.clj:5928)
    at clojure.core$load_lib$fn__6850.invoke(core.clj:5975)
    at clojure.core$load_lib.invokeStatic(core.clj:5974)
    at clojure.core$load_lib.doInvoke(core.clj:5953)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invokeStatic(core.clj:669)
    at clojure.core$load_libs.invokeStatic(core.clj:6016)
    at clojure.core$load_libs.doInvoke(core.clj:6000)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:669)
    at clojure.core$require.invokeStatic(core.clj:6038)
    at clojure.core$require.doInvoke(core.clj:6038)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at user$eval138$loading__6789__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:7194)
    at clojure.lang.Compiler.eval(Compiler.java:7183)
    at clojure.lang.Compiler.load(Compiler.java:7653)
    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.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.tools.analyzer.utils/update-vals
    at clojure.lang.Var$Unbound.throwArity(Var.java:45)
    at clojure.lang.AFn.invoke(AFn.java:36)
    at clojure.lang.AFn.applyToHelper(AFn.java:156)
    at clojure.lang.AFn.applyTo(AFn.java:144)
    at clojure.core$apply.invokeStatic(core.clj:669)
    at clojure.core$update_in$up__6922.invoke(core.clj:6220)
    at clojure.core$update_in$up__6922.invoke(core.clj:6219)
    at clojure.core$update_in.invokeStatic(core.clj:6221)
    at clojure.core$update_in.doInvoke(core.clj:6207)
    at clojure.lang.RestFn.invoke(RestFn.java:467)
    at clojure.tools.analyzer.passes.uniquify$uniquify_locals_around.invokeStatic(uniquify.clj:29)
    at clojure.tools.analyzer.passes.uniquify$uniquify_locals_around.invoke(uniquify.clj:26)
    at clojure.tools.analyzer.passes.uniquify$uniquify_locals.invokeStatic(uniquify.clj:95)
    at clojure.tools.analyzer.passes.uniquify$uniquify_locals.invoke(uniquify.clj:85)
    at clojure.lang.Var.invoke(Var.java:384)
    at clojure.core$comp$fn__5876.invoke(core.clj:2586)
    at clojure.core$comp$fn__5876.invoke(core.clj:2586)
    at clojure.core$comp$fn__5876.invoke(core.clj:2586)
    at clojure.core$comp$fn__5876.invoke(core.clj:2586)
    at clojure.core$comp$fn__5876.invoke(core.clj:2586)
    at clojure.core$comp$fn__5876.invoke(core.clj:2586)
    at clojure.tools.analyzer.jvm$analyze$fn__3707$fn__3712.invoke(jvm.clj:513)
    at clojure.tools.analyzer.jvm$analyze$fn__3707.invoke(jvm.clj:511)
    at clojure.lang.AFn.applyToHelper(AFn.java:152)
    at clojure.lang.AFn.applyTo(AFn.java:144)
    at clojure.core$apply.invokeStatic(core.clj:667)
    at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1990)
    at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1990)
    at clojure.lang.RestFn.invoke(RestFn.java:425)
    at clojure.tools.analyzer.jvm$analyze.invokeStatic(jvm.clj:500)
    at clojure.tools.analyzer.jvm$analyze.invoke(jvm.clj:480)
    at clojure.core.async.impl.ioc_macros$state_machine.invokeStatic(ioc_macros.clj:1102)
    at clojure.core.async.impl.ioc_macros$state_machine.invoke(ioc_macros.clj:1100)
    at clojure.core.async$go.invokeStatic(async.clj:463)
    at clojure.core.async$go.doInvoke(async.clj:441)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.lang.Var.applyTo(Var.java:705)
    at clojure.lang.Compiler.macroexpand1(Compiler.java:7010)
    ... 81 more
kovasap commented 3 months ago

I use the following commands to install my development app, in case they are necessary to repro: https://github.com/metasoarous/oz/commit/4602ece17fe62bd058d15200881d65f1da06f8f8

thheller commented 3 months ago

Looks to me like you are getting a bad mix of dependency conflicts.

https://github.com/clojure/tools.analyzer/blob/master/src/main/clojure/clojure/tools/analyzer/utils.clj#L10

This excludes update-vals, so you shouldn't be getting these WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer.utils, ... warnings.

So, my conclusion is that you are getting some old tools.analyzer version "incompatible" with Clojure 1.11.+. Nothing to do with shadow-cljs, as it just shells out to the clojure command and does absolutely nothing to modify deps.edn. Probably just need to sort out your deps.edn dependencies and resolve the conflicts.

kovasap commented 3 months ago

I tried removing all my dependencies, reinstalling clojure, and removing my ~/.m2 dir to refresh dependencies. I still have the same issue with the same error. Posted on Clojure slack to get some more eyes on the issue.

kovasap commented 3 months ago

I think you're right that this is not a shadow-cljs issue.

thheller commented 3 months ago

Wiping the dependencies does nothing if they just get restored in the same way. Since you are running deps.edn just use clj -Stree or so to sort out the dependency conflicts.

thheller commented 3 months ago

I just ran the compile on my machine and it worked fine. Could be that you have something in ~/.clojure/deps.edn that messes with dependencies in some ways?

kovasap commented 3 months ago

Ah! That helped me discover that oz has a clojupyter dep with an older tools.analyzer. I excluded this lib (marked as :optional) and now it works!

kovasap commented 3 months ago

See https://github.com/kovasap/biomarker-correlator/commit/8c63837baa99929612db95710a8458086d31f855

kovasap commented 3 months ago

I just ran the compile on my machine and it worked fine. Could be that you have something in ~/.clojure/deps.edn that messes with dependencies in some ways?

That is odd... I don't see anything there that could be related.