clojure-emacs / cider

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

Cider throws error when server is on Windows #2845

Closed Frozenlock closed 4 years ago

Frozenlock commented 4 years ago

Expected behavior

Cider works as it would when running the server a linux machine.

Actual behavior

Commands are sent but don't print anything back. An error is thrown.

Steps to reproduce the problem

Launch a server on a windows machine.

lein update-in :dependencies conj "[nrepl \"0.6.0\"]" -- update-in :plugins concat "[[cider/cider-nrepl \"0.24.0\"]]" -- update-in :pedantic? empty -- with-profile +dev,+test repl :headless :host localhost :port 6666

Then, from Emacs on your linux machine: M-x cider-connect ...

Error:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  compare-strings(nil 0 0 "/home/frozenlock/Docsolver/master/apps/basil/agent/" 0 0 nil)
  string-prefix-p(nil "/home/frozenlock/Docsolver/master/apps/basil/agent/")
  #f(compiled-function (path) #<bytecode 0x1136b4d>)(nil)
  #f(compiled-function (elt) #<bytecode 0x1136b65>)(nil)
  mapc(#f(compiled-function (elt) #<bytecode 0x1136b65>) (nil nil nil nil nil))
  seq-do(#f(compiled-function (elt) #<bytecode 0x1136b65>) (nil nil nil nil nil))
  seq-find(#f(compiled-function (path) #<bytecode 0x1136b4d>) (nil nil nil nil nil))
  #f(compiled-function (system session) #<bytecode 0x1bdf7d5>)(CIDER ("libs/bundle:vagrant-machine:6666" #<buffer *cider-repl libs/bundle:vagrant-machine:6666(clj)*>))
  apply(#f(compiled-function (system session) #<bytecode 0x1bdf7d5>) CIDER ("libs/bundle:vagrant-machine:6666" #<buffer *cider-repl libs/bundle:vagrant-machine:6666(clj)*>))
  sesman-friendly-session-p(CIDER ("libs/bundle:vagrant-machine:6666" #<buffer *cider-repl libs/bundle:vagrant-machine:6666(clj)*>))

Environment & Version information

CIDER version information

;; CIDER 0.24.0 (India), nREPL 0.6.0
;; Clojure 1.10.0, Java 11.0.6

Lein/Boot version

Leiningen 2.9.1 on Java 11.0.6 OpenJDK 64-bit Server VM

Emacs version

26.3

Operating system

Ubuntu 18.04.4 LTS Windows Server 2012 R2 Standard

kriyative commented 4 years ago

I think I reproduced this same issue on Linux so it may not be Windows specific. A mismatch between client and server nrepl versions may be at fault

;; CIDER 0.24.0 (India), nREPL 0.2.13
;; Clojure 1.10.1, Java 11.0.7

with the following warning:

WARNING: CIDER requires nREPL 0.6.0 (or newer) to work properly
         More information.WARNING: CIDER 0.24.0 requires cider-nrepl 0.24.0, but you're currently using cider-nrepl 0.17.0. The version mismatch might break some functionality!
         More information.

I was able to workaround the issue by adding the following fix:

modified   cider-connection.el
@@ -467,7 +467,7 @@ REPL defaults to the current REPL."
                                     cp))))
         (or (seq-find (lambda (path) (string-prefix-p path file))
                       classpath)
-            (seq-find (lambda (path) (string-prefix-p path file))
+            (seq-find (lambda (path) (and path (string-prefix-p path file)))
                       classpath-roots))))))

I presume this is expected given the ancient nrepl running on the server side (not much can be done about that in my case). Maybe, making the client side more defensive is a reasonable fix.

kriyative commented 4 years ago

On second examination, the fix actually belongs in the cache miss path a few lines above.

https://github.com/clojure-emacs/cider/pull/2858

Frozenlock commented 4 years ago

I recently updated to CIDER 0.26.1 and cider-nrepl 0.25.3 and I no longer encounter this issue.