clojure-emacs / cider

The Clojure Interactive Development Environment that Rocks for Emacs
https://cider.mx
GNU General Public License v3.0
3.55k stars 645 forks source link

cider-jack-in 0.18 fails on project where it used to work on v.0.15.0. #2459

Closed rmuslimov closed 6 years ago

rmuslimov commented 6 years ago

I'm trying to call cider-jack-in in my project which we working fine in cider v.0.15. However, currently I can understand what's going wrong with cider and why next error occurs.

Here is my project.clj

(defproject antonov "release.6.22.1"
  :description "OTA Standard SOAP server"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[bcd/otatree "1.2.0"]
                 [cheshire "5.8.0"]
                 [cider/cider-nrepl "0.18.0"]
                 [clj-dbcp "0.9.0"]
                 [clj-unidecode "1.0.2"]
                 [clojure-humanize "0.2.2"]
                 [com.draines/postal "2.0.2"]
                 [com.fzakaria/slf4j-timbre "0.3.12"]
                 [com.stuartsierra/component "0.3.2"]
                 [com.taoensso/carmine "2.18.1"]
                 [com.taoensso/timbre "4.10.0"]
                 [com.taoensso/tufte "2.0.1"]
                 [funcool/cats "2.2.0"]
                 [http-kit "2.3.0"]
                 [me.raynes/fs "1.4.6"]
                 [migratus "1.0.8"]
                 [org.bovinegenius/exploding-fish "0.3.6"]
                 [org.clojure/clojure "1.9.0"]
                 [org.clojure/java.data "0.1.1"]
                 [org.clojure/java.jdbc "0.7.8"]
                 [org.clojure/tools.cli "0.3.7"]
                 [org.clojure/tools.nrepl "0.2.13"]
                 [org.postgresql/postgresql "42.2.4"]
                 [pandect "0.6.1"]
                 [raven-clj "1.5.2"]
                 [reloaded.repl "0.2.4"]
                 [ses-mailer "0.0.4"]
                 [yesql "0.5.3"]
                 [yogthos/config "1.1.1"]]
  :main ^:skip-aot antonov.core
  :target-path "target/%s"
  :repositories [["private" {:url "s3://jvm-maven-repo/releases/"}]]
  :plugins [[lein-shell "0.5.0"]
            [lein-test-out "0.3.1"]
            [migratus-lein "0.4.7"]
            [s3-wagon-private "1.1.2"]]
  :resource-paths ["resources"]
  :migratus {:store :database
             :db ~(get (System/getenv) "DATABASE_URL")}
  :profiles {:dev {:source-paths ["dev"]
                   :plugins [[lein-ancient "0.6.15"]
                             [lein-bikeshed "0.4.1"]
                             [lein-cljfmt "0.5.6"]
                             [lein-cloverage "1.0.13"]
                             [lein-kibit "0.1.3"]
                             [lein-nvd "0.5.1"]
                             [jonase/eastwood "0.2.3"]]}
             :uberjar {:aot :all}}
  :jvm-opts ["-Dhttps.protocols=TLSv1.2"
             "-Djdk.tls.client.protocols=TLSv1.2"
             "-Dnewrelic.config.agent_enabled=false"]
  :java-agents [[com.newrelic.agent.java/newrelic-agent "4.4.0"]]
  :aliases {"joker" ["shell" "find" "src/antonov" "test/antonov"
                     "-name" "[^.]*.clj" "-exec" "joker" "--lint" "{}" ";"]
            "lint" ["do" ["joker"] ["kibit"] ["eastwood"] ["bikeshed"]
                    ["cljfmt" "check"]]
            "coverage" [["cloverage"]]
            "test-all" ["do" ["lint"] ["coverage"]]
            "unconfirmed" ["run" "-m" "antonov.tasks.unconfirmed"]
            "perf" ["run" "-m" "antonov.tasks.perf"]})

Actual behaviour

I'm calling cider-jack-in-clj and nrepl starts with next errors, all repl actions stuck and doesn't work.

java.lang.IllegalArgumentException: No method in multimethod 'op-handler' for dispatch value: null
 at clojure.lang.MultiFn.getFn (MultiFn.java:156)
    clojure.lang.MultiFn.invoke (MultiFn.java:233)
    cider.nrepl.middleware.util.error_handling$eval26929$fn__26930.invoke (error_handling.clj:162)
    clojure.lang.MultiFn.invoke (MultiFn.java:233)
    cider.nrepl.middleware.out$handle_out.invokeStatic (out.clj:127)
    cider.nrepl.middleware.out$handle_out.invoke (out.clj:126)
    clojure.lang.Var.invoke (Var.java:385)
    cider.nrepl$wrap_out$fn__1666.invoke (nrepl.clj:336)
    nrepl.middleware$wrap_conj_descriptor$fn__959.invoke (middleware.clj:15)
    cider.nrepl$wrap_trace$fn__1722.invoke (nrepl.clj:466)
    nrepl.middleware$wrap_conj_descriptor$fn__959.invoke (middleware.clj:15)
    cider.nrepl$wrap_macroexpand$fn__1650.invoke (nrepl.clj:295)
    nrepl.middleware$wrap_conj_descriptor$fn__959.invoke (middleware.clj:15)
    cider.nrepl$wrap_spec$fn__1698.invoke (nrepl.clj:420)
    nrepl.middleware$wrap_conj_descriptor$fn__959.invoke (middleware.clj:15)
    cider.nrepl.middleware.pprint$handle_pprint_fn.invokeStatic (pprint.clj:61)
    cider.nrepl.middleware.pprint$handle_pprint_fn.invoke (pprint.clj:56)
    clojure.lang.Var.invoke (Var.java:385)
    cider.nrepl$wrap_pprint_fn$fn__1546.invoke (nrepl.clj:100)
    nrepl.middleware$wrap_conj_descriptor$fn__959.invoke (middleware.clj:15)
    cider.nrepl$wrap_complete$fn__1598.invoke (nrepl.clj:172)
    nrepl.middleware$wrap_conj_descriptor$fn__959.invoke (middleware.clj:15)
    cider.nrepl$wrap_ns$fn__1658.invoke (nrepl.clj:308)
    nrepl.middleware$wrap_conj_descriptor$fn__959.invoke (middleware.clj:15)
    cider.nrepl$wrap_refresh$fn__1682.invoke (nrepl.clj:382)
    nrepl.middleware$wrap_conj_descriptor$fn__959.invoke (middleware.clj:15)
    cider.nrepl$wrap_classpath$fn__1590.invoke (nrepl.clj:166)
    nrepl.middleware$wrap_conj_descriptor$fn__959.invoke (middleware.clj:15)
    cider.nrepl$wrap_info$fn__1632.invoke (nrepl.clj:236)
    nrepl.middleware$wrap_conj_descriptor$fn__959.invoke (middleware.clj:15)
    cider.nrepl$wrap_resource$fn__1690.invoke (nrepl.clj:408)
    nrepl.middleware$wrap_conj_descriptor$fn__959.invoke (middleware.clj:15)
    cider.nrepl$wrap_format$fn__1624.invoke (nrepl.clj:222)
    nrepl.middleware$wrap_conj_descriptor$fn__959.invoke (middleware.clj:15)
    cider.nrepl$wrap_tracker$fn__1730.invoke (nrepl.clj:484)
    nrepl.middleware$wrap_conj_descriptor$fn__959.invoke (middleware.clj:15)
    cider.nrepl$wrap_debug$fn__1608.invoke (nrepl.clj:192)
    nrepl.middleware$wrap_conj_descriptor$fn__959.invoke (middleware.clj:15)
    cider.nrepl$wrap_content_type$fn__1566.invoke (nrepl.clj:139)
    nrepl.middleware$wrap_conj_descriptor$fn__959.invoke (middleware.clj:15)
    cider.nrepl$wrap_stacktrace$fn__1706.invoke (nrepl.clj:436)
    nrepl.middleware$wrap_conj_descriptor$fn__959.invoke (middleware.clj:15)
    clojure.tools.nrepl.server$handle_STAR_.invokeStatic (server.clj:19)
    clojure.tools.nrepl.server$handle_STAR_.invoke (server.clj:16)
    clojure.tools.nrepl.server$handle$fn__2606.invoke (server.clj:28)
    clojure.core$binding_conveyor_fn$fn__5476.invoke (core.clj:2022)
    clojure.lang.AFn.call (AFn.java:18)
    java.util.concurrent.FutureTask.run (FutureTask.java:266)
    java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
    java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
    java.lang.Thread.run (Thread.java:748)

If I go to nrepl buffer I can see there (I deleted all injected dependecies for clear test)

Retrieving refactor-nrepl/refactor-nrepl/2.4.0/refactor-nrepl-2.4.0.pom from clojars
Retrieving nrepl/nrepl/0.4.4/nrepl-0.4.4.pom from clojars
Retrieving refactor-nrepl/refactor-nrepl/2.4.0/refactor-nrepl-2.4.0.jar from clojars
Retrieving nrepl/nrepl/0.4.4/nrepl-0.4.4.jar from clojars
Retrieving nrepl/nrepl/0.4.5/nrepl-0.4.5.pom from clojars
Retrieving nrepl/bencode/1.0.0/bencode-1.0.0.pom from clojars
Retrieving nrepl/nrepl/0.4.5/nrepl-0.4.5.jar from clojars
Retrieving nrepl/bencode/1.0.0/bencode-1.0.0.jar from clojars
Sep 25, 2018 17:32:34 -0700 [40470 1] com.newrelic WARN: New Relic Agent is disabled by a system property.
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-apropos, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-classpath, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-complete, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-debug, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-enlighten, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-format, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-info, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-inspect, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-macroexpand, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-slurp, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-ns, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-out, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-content-type, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-slurp, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-pprint, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-pprint-fn, see clojure.tools.middleware/set-descriptor!
nREPL server started on port 60252 on host :: - nrepl://:::60252
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-profile, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-refresh, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-resource, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-spec, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-stacktrace, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-test, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-trace, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-tracker, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-undef, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-version, see clojure.tools.middleware/set-descriptor!

Expected behavior

All should works as expected, for example calling lein repl and refreshing-reloading code there works as suppossed to.

Steps to reproduce the problem

Calling cider-jack-in falls with described exception.

Environment & Version information

CIDER version information

;; CIDER 0.18.1snapshot (package: 20180923.1759), nREPL 0.2.13
;; Clojure 1.9.0, Java 1.8.0_152

Lein

Leiningen 2.8.1 on Java 1.8.0_152 Java HotSpot(TM) 64-Bit Server VM

Emacs version

GNU Emacs 26.1 (build 1, x86_64-apple-darwin17.5.0, NS appkit-1561.40 Version 10.13.4 (Build 17E202)) of 2018-06-11

Operating system

OS X 10.13.6 "High Sierra"

bbatsov commented 6 years ago

The problem is pretty simple - for some reason nREPL 0.4 gets loaded for you before nREPL 0.2 (which your lein currently uses), this messes up the runtime nREPL version detection and creates all those warnings:


[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-apropos, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-classpath, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-complete, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-debug, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-enlighten, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-format, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-info, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-inspect, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-macroexpand, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-slurp, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-ns, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-out, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-content-type, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-slurp, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-pprint, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-pprint-fn, see clojure.tools.middleware/set-descriptor!```

(which breaks the middleware)

I'll assume you have some `user.clj` file that's affecting the order in which libraries are loaded, right? (as this issue sounds just like https://github.com/thheller/shadow-cljs/issues/360) What's currently happening is that some package loaded nREPL 0.4 as it's dependency, but Lein 2.8.1 started an incompatible nREPL 0.2 server and it can't find any middleware for that reason. You can either see what's affecting the load order or update the `lein` from master or use `lein-nrepl` (both of them are using nREPL 0.4). 
rmuslimov commented 6 years ago

Thanks for detecting root of my problem, it almost there. In system I had cider-system component which we using nrepl of previous version. Since I'm not using it anymore, removing that code solved the issue.