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

Auto detect multiple nrepl connection options, if they exist #3140

Closed
zalky opened this issue Jan 25, 2022 · 2 comments · Fixed by #3234
Closed

Auto detect multiple nrepl connection options, if they exist #3140

zalky opened this issue Jan 25, 2022 · 2 comments · Fixed by #3234
Labels
enhancement good first issue A simple tasks suitable for first-time contributors

Comments

@zalky
Copy link

zalky commented Jan 25, 2022

Expected behavior

I often need to connect to both a clj nrepl server as well as a shadow-cljs nrepl server for full stack dev. Because the clj nrepl server prints its port to .nrepl-port, and shadow prints its port to .shadow-nrepl/nrepl.port, ideally their respective ports should both be automatically discoverable when I try to connect via cider-connect.

Actual behavior

If a clj nrepl server has already printed its port to .nrepl-port, cider-connect will fail to auto-detect the shadow nrepl server port in .shadow-nrepl/nrepl.port. With only a shadow nrepl server running, the shadow nrepl port is automatically detected.

Steps to reproduce the problem

Make sure you have both a clj nrepl server started as well as a shadow cljs nrepl server started before you try to connect to the shadow-cljs server via cider-connect.

I'm not super familiar with the code-base, but as best I can tell the conditional in nrepl-extract-port in nrepl-client.el will always return a single result and cause .nrepl-port to shadow .shadow-nrepl/nrepl.port. nrepl-extract-port might need to return a list.

Environment & Version information

CIDER version information

;; CIDER 1.1.0 (package: 1.1.0.1) (Plovdiv), nREPL 0.8.3
;; Clojure 1.10.3, Java 1.8.0_302

Emacs version

GNU Emacs 27.2 (build 1, x86_64-apple-darwin18.7.0)

Operating system

OSX 11.6.2

@vemv
Copy link
Member

vemv commented Jan 28, 2022

Sounds reasonable, would you give it a shot (https://docs.cider.mx/cider/contributing/hacking.html#hacking-on-cider-elisp) and propose/draft a PR that you have verified that works for you?

@bbatsov bbatsov added enhancement good first issue A simple tasks suitable for first-time contributors labels Jan 28, 2022
@zalky
Copy link
Author

zalky commented Jan 29, 2022

I'll try to take a crack at it once I'm able to carve out some free time.

danmidwood added a commit to danmidwood/cider that referenced this issue Aug 4, 2022
Searching for a nrepl port to connect to would return a maximum of one
port per project, ignoring any others that you might want to connect
to. This creates a case where when connecting to a shadow-cljs nrepl
server the port is not presented to you as a completion when you
already have another nrepl server running.

This commit changes nrepl-extract-port to nrepl-extract-ports and the
return type from a single port to a list of ports (including nils
where a specific project type nrepl port file doesn't exist) to
provide the full view of nrepl servers that are available in the
project, and then the cider-locate-running-nrepl-ports fn is changed
to accommodate that.

This fixes clojure-emacs#3140.
danmidwood added a commit to danmidwood/cider that referenced this issue Aug 10, 2022
Searching for a nrepl port to connect to would return a maximum of one
port per project, ignoring any others that you might want to connect
to. This creates a case where when connecting to a shadow-cljs nrepl
server the port is not presented to you as a completion when you
already have another nrepl server running.

This commit changes nrepl-extract-port to nrepl-extract-ports and the
return type from a single port to a list of ports (including nils
where a specific project type nrepl port file doesn't exist) to
provide the full view of nrepl servers that are available in the
project, and then the cider-locate-running-nrepl-ports fn is changed
to accommodate that.

This fixes clojure-emacs#3140.
danmidwood added a commit to danmidwood/cider that referenced this issue Aug 10, 2022
Searching for a nrepl port to connect to would return a maximum of one
port per project, ignoring any others that you might want to connect
to. This creates a case where when connecting to a shadow-cljs nrepl
server the port is not presented to you as a completion when you
already have another nrepl server running.

This commit changes nrepl-extract-port to nrepl-extract-ports and the
return type from a single port to a list of ports (including nils
where a specific project type nrepl port file doesn't exist) to
provide the full view of nrepl servers that are available in the
project, and then the cider-locate-running-nrepl-ports fn is changed
to accommodate that.

This fixes clojure-emacs#3140.
danmidwood added a commit to danmidwood/cider that referenced this issue Aug 10, 2022
Searching for a nrepl port to connect to would return a maximum of one
port per project, ignoring any others that you might want to connect
to. This creates a case where when connecting to a shadow-cljs nrepl
server the port is not presented to you as a completion when you
already have another nrepl server running.

This commit changes nrepl-extract-port to nrepl-extract-ports and the
return type from a single port to a list of ports (including nils
where a specific project type nrepl port file doesn't exist) to
provide the full view of nrepl servers that are available in the
project, and then the cider-locate-running-nrepl-ports fn is changed
to accommodate that.

This fixes clojure-emacs#3140.
bbatsov pushed a commit that referenced this issue Aug 10, 2022
Searching for a nrepl port to connect to would return a maximum of one
port per project, ignoring any others that you might want to connect
to. This creates a case where when connecting to a shadow-cljs nrepl
server the port is not presented to you as a completion when you
already have another nrepl server running.

This commit changes nrepl-extract-port to nrepl-extract-ports and the
return type from a single port to a list of ports (including nils
where a specific project type nrepl port file doesn't exist) to
provide the full view of nrepl servers that are available in the
project, and then the cider-locate-running-nrepl-ports fn is changed
to accommodate that.

This fixes #3140.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement good first issue A simple tasks suitable for first-time contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants