Fork me on GitHub
#cider
<
2022-03-03
>
jumar13:03:47

I'm trying figwheel-main and want to integrate it with emacs. I followed https://docs.cider.mx/cider/cljs/figwheel.html and https://figwheel.org/docs/emacs.html and my project (lein based) works with lein fig:build However, when I try to run cider-jack-in-clj&cljs I get this error

1. Unhandled java.lang.NullPointerException
   Null closurePrimitiveNames

     AutoValue_Config.java:  196  com.google.javascript.jscomp.parsing.AutoValue_Config$Builder/setClosurePrimitiveNames
         ParserRunner.java:   91  com.google.javascript.jscomp.parsing.ParserRunner/createConfig
             Compiler.java: 2686  com.google.javascript.jscomp.Compiler/createConfig
             Compiler.java: 2667  com.google.javascript.jscomp.Compiler/getParserConfig
                JsAst.java:  155  com.google.javascript.jscomp.JsAst/parse
                JsAst.java:   55  com.google.javascript.jscomp.JsAst/getAstRoot
               externs.clj:  169  cljs.externs/parse-externs
               externs.clj:  156  cljs.externs/parse-externs
               externs.clj:  204  cljs.externs/externs-map*/fn
             protocols.clj:   49  clojure.core.protocols/iter-reduce
             protocols.clj:   75  clojure.core.protocols/fn
             protocols.clj:   75  clojure.core.protocols/fn
             protocols.clj:   13  clojure.core.protocols/fn/G
                  core.clj: 6830  clojure.core/reduce
                  core.clj: 6812  clojure.core/reduce
               externs.clj:  201  cljs.externs/externs-map*
               externs.clj:  185  cljs.externs/externs-map*
               externs.clj:  189  cljs.externs/externs-map*
               externs.clj:  185  cljs.externs/externs-map*
                  AFn.java:  154  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  667  clojure.core/apply
                  core.clj: 6342  clojure.core/memoize/fn
               RestFn.java:  408  clojure.lang.RestFn/invoke
                  env.cljc:   51  cljs.env$default_compiler_env_STAR_/invokeStatic
                  env.cljc:   46  cljs.env$default_compiler_env_STAR_/invoke
                  env.cljc:   62  cljs.env$default_compiler_env/invokeStatic
                  env.cljc:   59  cljs.env$default_compiler_env/invoke
                 main.cljc: 2172  figwheel.main$default_compile/invokeStatic
                 main.cljc: 2167  figwheel.main$default_compile/invoke
                 main.cljc: 2291  figwheel.main$start_STAR_/invokeStatic
                 main.cljc: 2267  figwheel.main$start_STAR_/doInvoke
...
What can I do to make this work?

hkjels15:03:54

Haven’t seen this, but it looks like you don’t have a main function in your Clojure-code. Does it work to just jack into clj?

practicalli-johnny16:03:11

I use https://github.com/bhauman/figwheel-main-template to create projects that work with Cider jack-in

jumar04:03:40

Yeah, I tried that too. It works with the sample project - I'm not sure what's different in my setup. Maybe some dependency conflicts? Compared to the sample project my project has a significant server-side portion and I only include clojurescript relatd dependencies in the dev lein profile.

jumar16:03:08

Randomly clicking through the stacktrace of the error I realized there might be a version conflict. Cider opened a very old version of closure-compiler library (v20130603) but I have no idea where it is coming from. lein deps :tree only shows v2020315 (I also tried to specify it explicitly in project.clj with the same result). lein plugins :tree show an old v2016 version brought in by lein-doo plugin but it's still not this old v2013 thing.

jumar16:03:34

This is the default command used for cider-jack-in-clj&cljs

/usr/local/bin/lein update-in :dependencies conj \[nrepl/nrepl\ \"0.9.0\"\] -- update-in :dependencies conj \[refactor-nrepl/refactor-nrepl\ \"3.3.2\"\] -- update-in :dependencies conj \[cider/piggieback\ \"0.5.2\"\] -- update-in :plugins conj \[refactor-nrepl/refactor-nrepl\ \"3.3.2\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.28.1\"\] -- update-in :plugins conj \[mx.cider/enrich-classpath\ \"1.9.0\"\] -- update-in :middleware conj cider.enrich-classpath/middleware -- repl :headless :host localhost
I tried using the same thing for deps :tree but got rather confusing results
lein update-in :dependencies conj \[nrepl/nrepl\ \"0.9.0\"\] -- update-in :dependencies conj \[refactor-nrepl/refactor-nrepl\ \"3.3.2\"\] -- update-in :dependencies conj \[cider/piggieback\ \"0.5.2\"\] -- update-in :plugins conj \[refactor-nrepl/refactor-nrepl\ \"3.3.2\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.28.1\"\] -- update-in :plugins conj \[mx.cider/enrich-classpath\ \"1.9.0\"\] -- update-in :middleware conj cider.enrich-classpath/middleware -- deps :tree >& deps-cider.out
When I look into deps-cider.out I see this
less deps-cider.out
...
 [com.google.javascript/closure-compiler-unshaded "v20200315" :classifier "javadoc" :exclusions [[*]]]
 [com.google.javascript/closure-compiler-unshaded "v20200315" :classifier "sources" :exclusions [[*]]]
 [com.google.javascript/closure-compiler-unshaded "v20200315"]
   [args4j "2.0.26"]
...
 [com.google.javascript/closure-compiler "v20130603" :classifier "javadoc" :exclusions [[*]]]
 [com.google.javascript/closure-compiler "v20130603" :classifier "sources" :exclusions [[*]]]
so v20130603 is a top-level dependency but I don't know how that can be - it's definitely not in my project.clj and also not in the dependencies added by the command. Moreover, it seems there are only javadoc and sources but not the standard artifact like there is for closure-compiler-unshaded

jumar16:03:54

If I remove enrich.classpath there are way less dependencies and the mysterious v20130603 version is gone too!

lein update-in :dependencies conj \[nrepl/nrepl\ \"0.9.0\"\] -- update-in :dependencies conj \[refactor-nrepl/refactor-nrepl\ \"3.3.2\"\] -- update-in :dependencies conj \[cider/piggieback\ \"0.5.2\"\] -- update-in :plugins conj \[refactor-nrepl/refactor-nrepl\ \"3.3.2\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.28.1\"\] -- deps :tree > deps-cider.out
If I run cider-jack-in-clj&cljs without enrich.classpath it works!
/usr/local/bin/lein update-in :dependencies conj \[nrepl/nrepl\ \"0.9.0\"\] -- update-in :dependencies conj \[refactor-nrepl/refactor-nrepl\ \"3.3.2\"\] -- update-in :dependencies conj \[cider/piggieback\ \"0.5.2\"\] -- update-in :plugins conj \[refactor-nrepl/refactor-nrepl\ \"3.3.2\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.28.1\"\] -- repl :headless :host localhost
@U45T93RA6 do you have an idea why is this happening?

vemv22:03:17

I've been meaning to cut a new enrich-classpath release, sounds like now it's the time Please clearly save your project as a branch/etc so we can see if the fix worked Thanks!

jumar06:03:22

Great, thank you!

jumar08:03:45

I don't really know how enrich-classpath works but when I was looking at the list of dependencies and the problem I hit it seemed to me that it's not respecting exclusions and dependency version resolutions and instead it's trying to include every version of every library which could possibly end up on classpath because it's defined as a transitive dependency of some artifact. Even if the actuall classpath (as computed by leiningen) would never contain such artifact. That's why I think I ended up with an ancient version of closure-compiler being loaded by an ancient version of clojurescript

vemv15:03:38

> it seemed to me that it's not respecting exclusions and dependency version resolutions and instead it's trying to include every version of every library which could possibly end up on classpath because it's defined as a transitive dependency of some artifact. Could you describe this in specific terms? A GH issue would be welcome I can actually debug it at some point (for which I'll count on that you've saved this reproducible case as a named branch), but for now a description suffices

jumar15:03:17

Yeah, I can try to write down something more comprehensive 🙂

hoppy22:03:12

recently started happening for node repls using development tree of spacemacs, and most current shadow-cljs. Attempting to jack-in and/or connect - nrepl dies. There are no significant spacemacs changes aside from enabling clojure layer with LSP. If you need a play project: [email protected]:/Gnurdle/aoc2019.git is intended to be used this way. I'll also add that calva handles this atm, and spacemacs seems like it was working until very recently.

hoppy22:03:17

happy to help with debugging, but not sure what next step would be