Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cider-connect to existing nREPL server complains about refactor-nrepl not being available #2511

Closed
kohr-h opened this issue Nov 4, 2018 · 11 comments

Comments

@kohr-h
Copy link

kohr-h commented Nov 4, 2018

Update: original issue solved, but there's a (less severe) follow-up issue, see below.

This problem may or may not be related to nrepl/nrepl#74.

When starting an external nREPL server and connecting to it via cider-connect, the welcome text reports this:

;; WARNING: CIDER requires cider-nrepl to be fully functional. Many things will not work without it!

There's also a curious user-error: ‘ivy-done’ requires the nREPL op "classpath" (provided by cider-nrepl), which indicates that cider-nrepl isn't loaded.

Here's the project.clj file:

;;; project.clj
(defproject nrepl-minimal "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.9.0"]
                 [mount "0.1.14"]
                 [nrepl "0.4.5"]]
  :plugins [[cider/cider-nrepl "0.19.0-SNAPSHOT"]]
  :middleware [cider-nrepl.plugin/middleware]
  :main ^:skip-aot nrepl-minimal.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

Note: I'm explicitly using the cider-nrepl plugin to have it loaded. I've also used a version where the :middleware line wasn't there. I added it due to a warning by Leiningen (Git master version).

Here's to code to start the server:

;;; core.clj
(ns nrepl-minimal.core
  (:require [nrepl.server :as nrepl]
            [mount.core :as mount]
            [clojure.tools.logging :as log])
  (:gen-class))

(mount/defstate ^{:on-reload :noop} repl-server
  :start
  (try
    (log/info "starting nREPL server on port 7000")
    (nrepl/start-server :port 7000)
    (catch Throwable t
      (log/error t "failed to start nREPL")
      (throw t)))
  :stop
  (nrepl/stop-server repl-server))

(defn -main
  [& args]
  (mount/start-with-args nil))

Then I start the server with lein run and cider-connect to it.

For reference, here's the contents of the *nrepl-messages* buffer:

(-->
  id         "1"
  op         "clone"
  time-stamp "2018-11-04 23:02:07.141949988"
)
(<--
  id          "1"
  session     "f1ed9755-a15c-44fe-9d51-6dd1761ab594"
  time-stamp  "2018-11-04 23:02:07.149228871"
  new-session "ba411751-5eaf-4f2f-ac85-ca85c3fd5a5e"
  status      ("done")
)
(-->
  id         "2"
  op         "clone"
  time-stamp "2018-11-04 23:02:07.166472005"
)
(<--
  id          "2"
  session     "7a23334b-22d2-4138-bc94-6a87d5f4d5c1"
  time-stamp  "2018-11-04 23:02:07.170576924"
  new-session "b1b614fc-9ad2-4de1-9eca-fd7d6c1b0481"
  status      ("done")
)
(-->
  id         "3"
  op         "describe"
  session    "ba411751-5eaf-4f2f-ac85-ca85c3fd5a5e"
  time-stamp "2018-11-04 23:02:07.188070555"
)
(<--
  id         "3"
  session    "ba411751-5eaf-4f2f-ac85-ca85c3fd5a5e"
  time-stamp "2018-11-04 23:02:07.193478713"
  aux        (dict
               current-ns "user")
  ops        (dict
               clone       (dict)
               close       (dict)
               describe    (dict)
               eval        (dict)
               interrupt   (dict)
               load-file   (dict)
               ls-sessions (dict)
               stdin       (dict))
  status     ("done")
  versions   (dict
               clojure (dict
                         incremental    0
                         major          1
                         minor          9
                         version-string "1.9.0")
               java    (dict
                         incremental    "0"
                         major          "1"
                         minor          "8"
                         update         "181"
                         version-string "1.8.0_181")
               nrepl   (dict
                         incremental    5
                         major          0
                         minor          4
                         version-string "0.4.5"))
)
(-->
  id                       "4"
  op                       "eval"
  session                  "ba411751-5eaf-4f2f-ac85-ca85c3fd5a5e"
  time-stamp               "2018-11-04 23:02:07.211825644"
  code                     "(str *ns*)"
  inhibit-cider-middleware "true"
)
(<--
  id         "4"
  session    "ba411751-5eaf-4f2f-ac85-ca85c3fd5a5e"
  time-stamp "2018-11-04 23:02:07.218376651"
  ns         "user"
  value      "\"user\""
)
(<--
  id         "4"
  session    "ba411751-5eaf-4f2f-ac85-ca85c3fd5a5e"
  time-stamp "2018-11-04 23:02:07.262209589"
  status     ("done")
)
(-->
  id                       "5"
  op                       "eval"
  session                  "ba411751-5eaf-4f2f-ac85-ca85c3fd5a5e"
  time-stamp               "2018-11-04 23:02:07.275523015"
  code                     "(when (clojure.core/resolve 'clojure.main/repl-requires)
       (clojure.core/map clojure.core/require clojure.main/repl-requires))"
  inhibit-cider-middleware "true"
)
(<--
  id         "5"
  session    "ba411751-5eaf-4f2f-ac85-ca85c3fd5a5e"
  time-stamp "2018-11-04 23:02:07.286372802"
  ns         "user"
  value      "(nil nil nil)"
)
(<--
  id         "5"
  session    "ba411751-5eaf-4f2f-ac85-ca85c3fd5a5e"
  time-stamp "2018-11-04 23:02:07.329969137"
  status     ("done")
)
(-->
  id                       "6"
  op                       "eval"
  session                  "ba411751-5eaf-4f2f-ac85-ca85c3fd5a5e"
  time-stamp               "2018-11-04 23:02:07.350507079"
  code                     "(do (set! *print-length* 100))"
  inhibit-cider-middleware "true"
)
(<--
  id         "6"
  session    "ba411751-5eaf-4f2f-ac85-ca85c3fd5a5e"
  time-stamp "2018-11-04 23:02:07.357238495"
  ns         "user"
  value      "100"
)
(<--
  id         "6"
  session    "ba411751-5eaf-4f2f-ac85-ca85c3fd5a5e"
  time-stamp "2018-11-04 23:02:07.398141005"
  status     ("done")
)
(-->
  id         "7"
  op         "out-subscribe"
  session    "ba411751-5eaf-4f2f-ac85-ca85c3fd5a5e"
  time-stamp "2018-11-04 23:02:07.442107396"
)
(<--
  id         "7"
  op         "out-subscribe"
  session    "ba411751-5eaf-4f2f-ac85-ca85c3fd5a5e"
  time-stamp "2018-11-04 23:02:07.474627368"
  status     ("done" "unknown-op" "error")
)

Environment & Version information

CIDER version information

;; Connected to nREPL server - nrepl://localhost:7000
;; CIDER 0.19.0snapshot (package: 20181030.2222), nREPL 0.4.5
;; Clojure 1.9.0, Java 1.8.0_181

Lein/Boot version

Leiningen 2.8.2-SNAPSHOT on Java 1.8.0_181 OpenJDK 64-Bit Server VM

The same behavior occurs with earlier versions of lein.

Emacs version

GNU Emacs 25.2.2 (x86_64-pc-linux-gnu, GTK+ Version 3.22.21) of 2017-09-22, modified by Debian

Operating system

Linux pop-os 4.15.0-36-generic #39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
@kohr-h
Copy link
Author

kohr-h commented Nov 4, 2018

Okay, I found this section in the Troubleshooting docs and added the code to the project. That solves part 1.

Now I'm getting

WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.4.0 (package: 20180826.2149) and n/a, respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings.

I've added [refactor-nrepl "2.4.0"] to :plugins in my project file, but it doesn't change anything.

@kohr-h kohr-h changed the title cider-connect to existing nREPL server messes up cider-nrepl cider-connect to existing nREPL server complains about refactor-nrepl not being available Nov 4, 2018
@bbatsov
Copy link
Member

bbatsov commented Nov 5, 2018

I've added [refactor-nrepl "2.4.0"] to :plugins in my project file, but it doesn't change anything.

This plugin does something only when you're using lein repl to start nREPL. With the embedded server you need to build a handler explicitly yourself by combining all the middleware you'd like this handler to feature.

Btw, do you really need clj-refactor? I've noticed that many people tend to get it simply by virtue of using spacemacs. If you don't you can simply disable or remove it and the warning will go away.

@kohr-h
Copy link
Author

kohr-h commented Nov 5, 2018

This plugin does something only when you're using lein repl to start nREPL. With the embedded server you need to build a handler explicitly yourself by combining all the middleware you'd like this handler to feature.

Okay, that makes sense. Not sure if I'm ready to do this yet, I'm still a Clojure newbie 😕

Btw, do you really need clj-refactor? I've noticed that many people tend to get it simply by virtue of using spacemacs. If you don't you can simply disable or remove it and the warning will go away.

As of now, no. If it's not an essential part of CIDER then I'm probably not gonna miss it.

@kohr-h
Copy link
Author

kohr-h commented Nov 5, 2018

Anyway, I'll close this then. Thanks for clearing things up @bbatsov

@kohr-h kohr-h closed this as completed Nov 5, 2018
@bbatsov
Copy link
Member

bbatsov commented Nov 5, 2018

As of now, no. If it's not an essential part of CIDER then I'm probably not gonna miss it.

No, it's not. It's the biggest extension CIDER has and at some point we plan a merger of the projects, but you can go pretty far without using clj-refactor and refactor-nrepl.

@dcguim
Copy link

dcguim commented Jul 31, 2019

I am having the same issue, on *nrepl-messages*
(<-- id "6" op "out-subscribe" session "b1f960d6-1322-4168-bdc2-54051f67e84c" time-stamp "2019-07-31 22:31:32.619400000" status ("done" "unknown-op" "error") )
and on *Messages*
user-error: ‘exit-minibuffer’ requires the nREPL op "classpath" (provided by cider-nrepl)

I have dependencies
[cider/nrepl "0.3.0"]
[nrepl "0.6.0"]

and plugin
[cider/cider-nrepl "0.21.0"]
the same version of the cider installed on my emacs.

My setup is basically a blank Luminus project, and I am simply trying to cider-connect to the nREPL on port 7000 fired by 'lein run'. Still I am getting

WARNING: CIDER requires cider-nrepl to be fully functional. Many things will not work without it!

@bbatsov
Copy link
Member

bbatsov commented Aug 2, 2019

[cider/nrepl "0.3.0"]

You don't need this one. It's something that I would ideally remove from Clojars (it was never announced and never intended to be used by anyone) as it confuses people from time to time. There are a few artefacts here and there that were just pushed with bad coordinates and are now left to haunt us. :-) //cc @danielcompton

What's your lein version?

@dcguim
Copy link

dcguim commented Aug 2, 2019

Leiningen 2.9.1 on Java 1.8.0_101 Java HotSpot(TM) 64-Bit Server VM

@bbatsov
Copy link
Member

bbatsov commented Aug 2, 2019

And removing cider/nrepl doesn't help?

@dcguim
Copy link

dcguim commented Aug 2, 2019

No, still see the warning.

@dmg46664
Copy link

@bbatsov

Please could I ask for assistance with the middleware handlers to setup refactor-nrepl as middleware in an embedded nrepl given that the suggested methodology (i.e. https://github.com/nrepl/piggieback#embedded) conflicts with the cider nrepl handler: clojure-emacs/cider-nrepl#447
&
clojure-emacs/cider-nrepl#464

Clojure noob here. I am presuming that the local handler has to take an argument and pass it to the returning function somehow.

It would be great if this was documented in full at the following location rather than the one without middleware https://docs.cider.mx/cider-nrepl/usage.html#_via_embedding_nrepl_in_your_app 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants