Skip to content

When using cider-connect with localhost nrepls running, those ports are not shown among the available ones #3390

@ag91

Description

@ag91

Expected behavior

For a running nrepl on localhost, I expected (cider-select-endpoint) to allow me to select ports on which nrepl is running.
(I use this to connect ob-clojure buffers to cider when doing literate programming and a bit of completion comes handy)

Fixes #3390

Actual behavior

It requires me to input the port manually.

Steps to reproduce the problem

  1. cider-jack-in without a project
  2. cider-connect from another clj buffer
  3. follow instructions to get to the cider session you opened before
  4. see that there are no available ports

or more specifically:

  1. eval in emacs (cider--running-nrepl-paths)
  2. see an empty output sigh!

My solution

Just for curiosity, I redefined cider--running-nrepl-paths (which seems to be the culprit) as follows:

(defun cider--running-nrepl-paths ()
  "Retrieve project paths of running nREPL servers.
Use `cider-ps-running-nrepls-command' and
`cider-ps-running-nrepl-path-regexp-list'."
  (seq-uniq
   (seq-map
    (lambda (b)
      (with-current-buffer b default-directory))
    (seq-filter
     (lambda (b) (string-prefix-p "*cider-repl" (buffer-name b)))
     (buffer-list)))))

That way things seem to work fine (for localhost).
I opened an issue because I think cider-ps-running-nrepls-command and cider-ps-running-nrepl-path-regexp-list are somewhat outdated. I replaced the behavior going via Emacs active buffers.
Any chance you can clarify why cider is looking for active nrepl via a terminal command (greping for leiningen -- I didn't find anything using that command manually)?

If this solution seems useful, I could look into opening a PR :)

CIDER version information

1.8.0-snapshot

Lein / Clojure CLI version

lein 2.9.1 / 1.10.3

Emacs version

28.1

Operating system

Ubuntu 22.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions