clojure-emacs / cider

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

nREPL doesn't work on Windows #2963

Closed Prometheus77 closed 3 years ago

Prometheus77 commented 3 years ago

Expected behavior:

When editing a .clj file in Clojure-mode, cider-jack-in-clj should start the REPL.

Observed behavior:

cider-jack-in-clj throws an error: Could not start nREPL server: java.lang.NumberFormatException: Invalid number: 0.8.3

More details here:

https://stackoverflow.com/questions/65566706/error-in-process-sentinel-could-not-start-nrepl-server-java-lang-numberformate

StargazeSparkle commented 3 years ago

I have experienced this same issue having installed cider today on W10. The command that it is running is as follows:

cmd.exe /d /c lein update-in :dependencies conj [nrepl,"0.8.3"] -- update-in :dependencies conj [clj-kondo,"2020.04.05"] -- update-in :plugins conj [cider/cider-nrepl,"0.25.6"] -- update-in [:repl-options,:nrepl-middleware] conj '["cider.nrepl/cider-middleware"]' -- repl :headless

https://user-images.githubusercontent.com/66642904/103757568-f49a0280-4fde-11eb-8c52-484c32936681.mp4

bbatsov commented 3 years ago

I guess that's some peculiarity of the Windows command-line, but I'm not familiar with it. @PEZ any ideas?

PEZ commented 3 years ago

We have reports from some Windows users about quoting issues. Seems to be related to Leiningen and how it is invoked. Very fuzzy so far, but just the latest days there seem to be hope. Check this out https://github.com/BetterThanTomorrow/calva/issues/387

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

CloseToZero commented 3 years ago

A quick and dirty fix (works on CIDER 1.1 and Leiningen 2.9.6):

(with-eval-after-load 'cider
  (when (eq system-type 'windows-nt)
    (define-advice cider--list-as-lein-artifact (:override (list &optional exclusions))
      "Add missing double quotes around the version string for cmd.exe."
      (shell-quote-argument
       (format "[%s \"%S\"%s]" (car list) (cadr list) (cider--lein-artifact-exclusions exclusions))))))

This works for cmd.exe. I guess the double quotes added by shell-quote-argument may be eaten by lein.bat, I'm not sure. For other kinds of projects (e.g. Boot projects), you may need to do similar things.

omarpta commented 3 years ago

I'm facing the same problem:

cmd.exe /d /c lein update-in :dependencies conj [nrepl,"0.8.3"] -- update-in :plugins conj [cider/cider-nrepl,"0.26.0"] -- update-in [:repl-options,:nrepl-middleware] conj '["cider.nrepl/cider-middleware"]' -- with-profile +uberjar repl :headless

Leiningen: 2.9.6 Java SDK: 11.0.11

calva02

calva01

PEZ commented 3 years ago

This could be a bug in the java.exe used. Check where java and if that shows something with Oracle and something with javapath in it, then that is the problem. And the solution is then to use another java.

omarpta commented 3 years ago

Yes, I just installed the OpenJDK 11 and everything is working now. Thanks

PEZ commented 3 years ago

Thanks for confirming. Then it is this bug: https://bugs.openjdk.java.net/browse/JDK-8266473

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!