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

error in process filter: [nREPL] Direct connection failed #1812

Closed stardiviner closed 8 years ago

stardiviner commented 8 years ago

I got error message in *Messages* buffer:

[nREPL] Establishing direct connection to localhost:36173 ...
error in process filter: nrepl--direct-connect: [nREPL] Direct connection failed
error in process filter: [nREPL] Direct connection failed

I toggle debug-on-error, got this message:

Debugger entered--Lisp error: (error "[nREPL] Direct connection failed")
  signal(error ("[nREPL] Direct connection failed"))
  error("[nREPL] Direct connection failed")
  nrepl--direct-connect("localhost" 33704)
  nrepl-connect(nil 33704)
  nrepl-start-client-process(nil 33704 #<process nrepl-server>)
  nrepl-server-filter(#<process nrepl-server> "nREPL server started on port 33704 on host 127.0.0.1 - nrepl://127.0.0.1:33704\n")

And here is my environment info:

Emacs compile from Git repo source code: 25.1.50.11
CIDER: 0.13.0snapshot (20160723.512)
Arch Linux

And here is my Leiningen profiles.clj content:

{
 :user
 {:plugins
  [
   [lein-pprint "1.1.1"]
   [lein-cprint "1.0.0"]
   ;; check outdated libraries
   [lein-ancient "0.6.10"]

   ;; Profile
   ;; for Emacs `cider-profile`
   [thunknyc/profile "0.5.2"]

   ;; ClojureScript Figwheel
   [lein-cljsbuild "1.0.0-alpha2"]      ; for ClojureScript `cljsbuild`
   [lein-figwheel "0.5.4-7"]
   ]
  }

 ;;; CIDER nrepl
 :repl
 {:dependencies
  [
   [org.clojure/clojure "1.8.0"]               ; Clojure
   ;; [org.clojure/tools.analyzer "0.6.9"]        ; Clojure analyzer
   [org.clojure/tools.nrepl "0.2.12"]          ; for Emacs/CIDER
   [acyclic/squiggly-clojure "0.1.6"] ; for Emacs/flycheck-clojure

   [org.clojure/clojurescript "1.9.89"]        ; ClojureScript
   ;; [org.clojure/tools.analyzer.js "0.1.0-beta5"] ; ClojureScript JS analyzer

   ;; ClojureScript REPL
   [com.cemerick/piggieback "0.2.1"]
   ;; [com.cemerick/austin "0.1.5"]
   [figwheel-sidecar "0.5.0-2"]
   ;; [weasel "0.7.0"]
   [slamhound "1.5.5"] ; Slamhound rips your namespace form apart and reconstructs it.
   ]

  :plugins
  [
   [cider/cider-nrepl "0.13.0-SNAPSHOT"]         ; for Emacs/CIDER
   [refactor-nrepl "2.0.0"]             ; for Emacs/clj-refactor
   ]

  ;; :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}
  }

 ;;; ClojureScript

 }

And here is my cider config:

(use-package cider
  :ensure t
  :config
  (setq cider-auto-mode t
        nrepl-hide-special-buffers t
        cider-auto-select-error-buffer t
        nrepl-buffer-name-separator " "
        nrepl-buffer-name-show-port nil

        ;; resources
        cider-prefer-local-resources t

        ;; font-lock
        cider-font-lock-dynamically '(macro core deprecated function)

        ;; indent
        cider-dynamic-indentation t

        ;; REPL
        cider-inject-dependencies-at-jack-in t
        cider-repl-display-in-current-window nil
        cider-repl-pop-to-buffer-on-connect nil
        cider-prompt-save-file-on-load t
        cider-repl-result-prefix ";; => "
        cider-interactive-eval-result-prefix ";; => "
        cider-repl-use-clojure-font-lock t
        ;; cider-repl-tab-command 'cider-repl-indent-and-complete-symbol
        ;; cider-known-endpoints '(("host-a" "10.10.10.1" "7888") ("host-b" "7888"))
        cider-repl-use-pretty-printing t
        cider-repl-wrap-history t
        cider-repl-history-size 500
        cider-repl-history-file nil
        cider-show-error-buffer 'only-in-repl

        ;; pretty-printing
        cider-pprint-fn 'fipp

        ;; Eval
        cider-show-eval-spinner t
        cider-use-overlays 'both
        cider-overlays-use-font-lock t ; use overlay for results.
        cider-result-use-clojure-font-lock t
        cider-eval-result-duration nil

        ;; Enlighten

        ;; mouse over tooltips
        cider-use-tooltips t

        ;; Compilation
        cider-auto-jump-to-error 'errors-only
        cider-auto-select-error-buffer t

        ;; clojure.test
        cider-test-show-report-on-success nil

        ;; stacktraces
        cider-show-error-buffer t
        cider-auto-select-error-buffer t
        cider-stacktrace-default-filters '(tooling dup)

        ;; debugging

        ;; code reloading
        cider-refresh-show-log-buffer t

        ;; multiple connections
        cider-request-dispatch 'dynamic

        ;; Mode Line
        cider-mode-line-show-connection t

        ;; project
        cider-prompt-for-project-on-connect 'when-needed
        )

  ;; Complete & annotations
  (setq cider-completion-use-context t
        cider-annotate-completion-candidates t
        ;; cider-annotate-completion-function
        cider-completion-annotations-include-ns 'always ; 'unqualified
        )

  ;; enable `cider-mode' in `clojure-mode'.
  (add-hook 'clojure-mode-hook #'cider-mode)

  ;; auto completion with company-mode support
  ;; `cider-complete-at-point' in `completion-at-point-functions'
  (add-hook 'cider-repl-mode-hook #'company-mode)
  (add-hook 'cider-mode-hook #'company-mode)

  ;; switch to cider-repl buffer.
  (defun my-cider-launch ()
    (interactive)
    (let ((cider-clojure-repl "*cider-repl localhost*")
          ;; TODO: update cljs repl buffer name
          (cider-cljs-repl "*cider-repl CLJS localhost*")
          (cider-connection-process "nrepl-connection")
          (cider-server-process "nrepl-server"))
      (unless (and (get-buffer cider-clojure-repl)
                   ;; TODO: enable this detect
                   ;; (get-buffer cider-cljs-repl)
                   (process-live-p (get-process cider-connection-process))
                   (process-live-p (get-process cider-server-process)))
        (message "CIDER REPL buffer not available. starting a new one now...")
        (cider-jack-in))))

  ;; ClojureScript REPL
  ;; (setq cider-cljs-lein-repl
  ;;       ;; default
  ;;       ;; "(cemerick.piggieback/cljs-repl (cljs.repl.rhino/repl-env))"
  ;;       ;; Figwheel-sidecar
  ;;       "(do (require 'figwheel-sidecar.repl-api) (figwheel-sidecar.repl-api/start-figwheel!) (figwheel-sidecar.repl-api/cljs-repl))"
  ;;       ;; Weasel
  ;;       ;; "(do (require 'weasel.repl.websocket) (cemerick.piggieback/cljs-repl (weasel.repl.websocket/repl-env :ip \"127.0.0.1\" :port 9001)))"
  ;;       )

  (defun my-cider-switch-to ()
    (interactive)
    (my-cider-launch)
    (let ((cider-repl "*cider-repl localhost*"))
      (switch-to-buffer cider-repl)))

  ;; auto start CIDER jack-in.
  ;; (add-hook 'clojure-mode-hook 'my-cider-launch)
  (add-hook 'after-init-hook 'my-cider-launch)

  (define-key clojure-mode-map (kbd "C-c C-s") 'my-cider-switch-to)
  (define-key my-inferior-lisp-map (kbd "c") 'my-cider-switch-to)
  )
bbatsov commented 8 years ago

That's odd. I'm guessing this started happening recently? I don't see anything in the backtrace that points to the nature of the problem. I'm assuming you can connect to this nREPL server with other clients, right?

stardiviner commented 8 years ago

@bbatsov Yes, it happened recently. I don't know how to connect to this nREPL server with other clients. Can you give me a little hint?

bbatsov commented 8 years ago

You can use reply or even something as basic as telnet. We haven't done anything major on master in quite a while, so I'm pretty puzzled that such a problem appeared out of nowhere.

stardiviner commented 8 years ago

Solved problem after I recompile Emacs 25 source code. I check out commit 60dd094a. Then recompile source code again. Emacs can connect to CIDER nREPL now. So the problem is on "Emacs 25 source code" recently commits.

bbatsov commented 8 years ago

OK, guess we can close this then.