nrepl / piggieback

nREPL support for ClojureScript REPLs
480 stars 48 forks source link

Runtime exception when installing piggieback on Clojure 1.9 + Java 9 #78

Closed vkz closed 5 years ago

vkz commented 6 years ago
java -version
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

brew ls clojure
/usr/local/Cellar/clojure/1.9.0.273/bin/clj
/usr/local/Cellar/clojure/1.9.0.273/bin/clojure
/usr/local/Cellar/clojure/1.9.0.273/deps.edn
/usr/local/Cellar/clojure/1.9.0.273/example-deps.edn
/usr/local/Cellar/clojure/1.9.0.273/libexec/clojure-tools-1.9.0.273.jar

deps.edn to reproduce

{:deps
 {clj-time {:mvn/version "0.14.2"}
  org.clojure/clojurescript {:mvn/version "1.9.946"}
  cljsjs/react {:mvn/version "16.2.0-1"}}

 :aliases {:dev {:extra-deps { ;; cider/cider-nrepl {:mvn/version "0.16.0-SNAPSHOT"}
                              org.clojure/tools.nrepl {:mvn/version "0.2.12"}
                              com.cemerick/piggieback {:mvn/version "0.2.2"}}
                 :extra-paths ["dev"]}}}

Command to reproduce: clj -J'--add-modules=java.xml.bind' -R:dev -C:dev

Result while downloading and compiling:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at clojure.main.<clinit>(main.java:20)
Caused by: java.lang.RuntimeException: Unable to find static field: UNUSED_LOCAL_VARIABLE in class com.google.javascript.jscomp.DiagnosticGroups, compiling:(cljs/closure.clj:100:1)
    at clojure.lang.Compiler.analyze(Compiler.java:6792)
    at clojure.lang.Compiler.analyze(Compiler.java:6729)
    at clojure.lang.Compiler$MapExpr.parse(Compiler.java:3097)
    at clojure.lang.Compiler.analyze(Compiler.java:6781)
    at clojure.lang.Compiler.access$300(Compiler.java:38)
    at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:595)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:7003)
    at clojure.lang.Compiler.analyze(Compiler.java:6773)
    at clojure.lang.Compiler.analyze(Compiler.java:6729)
    at clojure.lang.Compiler.eval(Compiler.java:7066)
    at clojure.lang.Compiler.load(Compiler.java:7514)
    at clojure.lang.RT.loadResourceScript(RT.java:379)
    at clojure.lang.RT.loadResourceScript(RT.java:370)
    at clojure.lang.RT.load(RT.java:460)
    at clojure.lang.RT.load(RT.java:426)
    at clojure.core$load$fn__6548.invoke(core.clj:6046)
    at clojure.core$load.invokeStatic(core.clj:6045)
    at clojure.core$load.doInvoke(core.clj:6029)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invokeStatic(core.clj:5848)
    at clojure.core$load_one.invoke(core.clj:5843)
    at clojure.core$load_lib$fn__6493.invoke(core.clj:5888)
    at clojure.core$load_lib.invokeStatic(core.clj:5887)
    at clojure.core$load_lib.doInvoke(core.clj:5868)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invokeStatic(core.clj:659)
    at clojure.core$load_libs.invokeStatic(core.clj:5925)
    at clojure.core$load_libs.doInvoke(core.clj:5909)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:659)
    at clojure.core$require.invokeStatic(core.clj:5947)
    at clojure.core$require.doInvoke(core.clj:5947)
    at clojure.lang.RestFn.invoke(RestFn.java:2793)
    at cljs.repl$eval956$loading__6434__auto____957.invoke(repl.cljc:9)
    at cljs.repl$eval956.invokeStatic(repl.cljc:9)
    at cljs.repl$eval956.invoke(repl.cljc:9)
    at clojure.lang.Compiler.eval(Compiler.java:7062)
    at clojure.lang.Compiler.eval(Compiler.java:7051)
    at clojure.lang.Compiler.load(Compiler.java:7514)
    at clojure.lang.RT.loadResourceScript(RT.java:379)
    at clojure.lang.RT.loadResourceScript(RT.java:370)
    at clojure.lang.RT.load(RT.java:460)
    at clojure.lang.RT.load(RT.java:426)
    at clojure.core$load$fn__6548.invoke(core.clj:6046)
    at clojure.core$load.invokeStatic(core.clj:6045)
    at clojure.core$load.doInvoke(core.clj:6029)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invokeStatic(core.clj:5848)
    at clojure.core$load_one.invoke(core.clj:5843)
    at clojure.core$load_lib$fn__6493.invoke(core.clj:5888)
    at clojure.core$load_lib.invokeStatic(core.clj:5887)
    at clojure.core$load_lib.doInvoke(core.clj:5868)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invokeStatic(core.clj:659)
    at clojure.core$load_libs.invokeStatic(core.clj:5925)
    at clojure.core$load_libs.doInvoke(core.clj:5909)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:659)
    at clojure.core$require.invokeStatic(core.clj:5947)
    at clojure.core$require.doInvoke(core.clj:5947)
    at clojure.lang.RestFn.invoke(RestFn.java:619)
    at cemerick.piggieback$eval950$loading__6434__auto____951.invoke(piggieback.clj:1)
    at cemerick.piggieback$eval950.invokeStatic(piggieback.clj:1)
    at cemerick.piggieback$eval950.invoke(piggieback.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:7062)
    at clojure.lang.Compiler.eval(Compiler.java:7051)
    at clojure.lang.Compiler.load(Compiler.java:7514)
    at clojure.lang.RT.loadResourceScript(RT.java:379)
    at clojure.lang.RT.loadResourceScript(RT.java:370)
    at clojure.lang.RT.load(RT.java:460)
    at clojure.lang.RT.load(RT.java:426)
    at clojure.core$load$fn__6548.invoke(core.clj:6046)
    at clojure.core$load.invokeStatic(core.clj:6045)
    at clojure.core$load.doInvoke(core.clj:6029)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invokeStatic(core.clj:5848)
    at clojure.core$load_one.invoke(core.clj:5843)
    at clojure.core$load_lib$fn__6493.invoke(core.clj:5888)
    at clojure.core$load_lib.invokeStatic(core.clj:5887)
    at clojure.core$load_lib.doInvoke(core.clj:5868)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invokeStatic(core.clj:659)
    at clojure.core$load_libs.invokeStatic(core.clj:5925)
    at clojure.core$load_libs.doInvoke(core.clj:5909)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:659)
    at clojure.core$require.invokeStatic(core.clj:5947)
    at clojure.core$require.doInvoke(core.clj:5947)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at user$eval13$loading__6434__auto____14.invoke(user.clj:1)
    at user$eval13.invokeStatic(user.clj:1)
    at user$eval13.invoke(user.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:7062)
    at clojure.lang.Compiler.eval(Compiler.java:7051)
    at clojure.lang.Compiler.load(Compiler.java:7514)
    at clojure.lang.RT.loadResourceScript(RT.java:379)
    at clojure.lang.RT.loadResourceScript(RT.java:366)
    at clojure.lang.RT.maybeLoadResourceScript(RT.java:362)
    at clojure.lang.RT.doInit(RT.java:482)
    at clojure.lang.RT.<clinit>(RT.java:336)
    ... 1 more
Caused by: java.lang.RuntimeException: Unable to find static field: UNUSED_LOCAL_VARIABLE in class com.google.javascript.jscomp.DiagnosticGroups
    at clojure.lang.Util.runtimeException(Util.java:221)
    at clojure.lang.Compiler.analyzeSymbol(Compiler.java:7196)
    at clojure.lang.Compiler.analyze(Compiler.java:6752)
    ... 100 more

Note, that cljs compiler seems to work fine. At least I haven't run into any issues performing all steps from Cljs Quick Start guide. That includes building and starting browser repl. Did it with cljs from deps.edn not with a standalone jar.

May be an issue with Clojure/Cljs or Java 9. Please let me know if worth reporting upstream.

thheller commented 6 years ago
Downloading: com/google/javascript/closure-compiler/v20150126/closure-compiler-v20150126.jar from https://repo1.maven.org/maven2/

An ancient version of the Closure Compiler is included for some reason. That is the cause, it is not related to Java 9 or Clojure 1.9.

cemerick commented 6 years ago

It looks like clj is choosing the gclosure dependency from piggieback's CLJS version instead of the one you're requesting in deps.edn?

If there's a way to exclude transitive dependencies, I would suggest explicitly excluding piggieback's CLJS dep so that clj resolves using your own.

vkz commented 6 years ago

Well spotted @thheller thank you. I should've thought about transitive dependencies. Trouble is clj caches resolved deps locally in the project directory and wouldn't re-download if what's been resolved is present in .m2, so I had to nuke .cpcache and delete old cljs from .m2 to see what you noticed. Indeed the resolver appears to pick the older cljs from piggieback - bit unintuitive to me. Wonder if I should report this upstream.

As @cemerick suggested I forced resolution like so:

{:deps
 {clj-time {:mvn/version "0.14.2"}
  org.clojure/clojurescript {:mvn/version "1.9.946"}}

 :aliases {:dev {:extra-deps { ;; cider/cider-nrepl {:mvn/version "0.16.0-SNAPSHOT"}
                              org.clojure/tools.nrepl {:mvn/version "0.2.12"}
                              com.cemerick/piggieback {:mvn/version "0.2.2"}}
                 :override-deps {org.clojure/clojurescript {:mvn/version "1.9.946"}}
                 :extra-paths ["dev"]}}}

tbh I smell trouble with this behavior of the resolver in tools.deps. Pushing piggieback and tools.nrepl deps from aliases to :deps produces the same problematic result. Sadly tools.deps reference doesn't go into details of how the resolver works.

I suppose we can close this issue. Thank you for your help.

bbatsov commented 6 years ago

@bhauman just bumped the cljs dep, so I guess that problem is solved now.

tirkarthi commented 6 years ago

I think the latest Clojurescript release 1.10 fixes JDK 9 compatibility issue caused by xml-bind. Relevant JIRA issue : https://dev.clojure.org/jira/browse/CLJS-2377 . Upgrading it might resolve the issue.