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

repl stays in pending state after clojurescript jack in if there's some buffer with an invalid ns declaration #2849

Closed
Andre0991 opened this issue May 24, 2020 · 2 comments · Fixed by #3428
Labels
bug good first issue A simple tasks suitable for first-time contributors

Comments

@Andre0991
Copy link

Andre0991 commented May 24, 2020

This error occurs when there's some buffer in clojure-mode with an invalid ns declaration (such as (ns ).

It seems that the culprit is clojure-find-ns (see the stacktrace below), which does not fail gracefully if it can't identify the ns in a buffer. It's not clear from its docstring if throwing an error is its expected behaviour when the ns form is invalid. That's why I'm opening the bug in this repo - I'm not sure if this situation should be handled by cider or clojure-mode, but it does affect cider.

I use Spacemacs, if that's relevant.

Expected behavior

Cider would jack in without errors.

Actual behavior

I got this error (I'm using toggle-debug-on-error):

Debugger entered--Lisp error: (scan-error "Containing expression ends prematurely" 5 6)
  scan-sexps(5 1)
  forward-sexp(1)
  clojure-forward-logical-sexp()
  clojure--find-ns-in-direction(backward)
  clojure-find-ns()
  cider-current-ns()
  cider-refresh-dynamic-font-lock()
  cider-mode(1)
  cider-enable-on-existing-clojure-buffers()
  #f(compiled-function () #<bytecode 0x477bb459>)()
  #f(compiled-function (buffer) #<bytecode 0x4770c08d>)(#<buffer *cider-repl nu/timeline:localhost:63972(pending-cljs)*>)
  #f(compiled-function (response) #<bytecode 0x4770c109>)((dict "id" "4" "session" "f0733cfc-31b2-4759-bb10-2416c787fa6f" "status" ("done")))
  #f(compiled-function (response) #<bytecode 0x4770c151>)((dict "id" "4" "session" "f0733cfc-31b2-4759-bb10-2416c787fa6f" "status" ("done")))
  nrepl--dispatch-response((dict "id" "4" "session" "f0733cfc-31b2-4759-bb10-2416c787fa6f" "status" ("done")))
  nrepl-client-filter(#<process nrepl-connection> "d2:id1:47:session36:f0733cfc-31b2-4759-bb10-2416c787fa6f5:value3:niled2:id1:42:ns11:shadow.user7:session36:f0733cfc-31b2-4759-bb10-2416c787fa6fed2:id1:47:session36:f0733cfc-31b2-4759-bb10-2416c787fa6f6:statusl4:doneee")

Steps to reproduce the problem

  • Create a clojure buffer with the following content: (ns ).
  • Use cider-jack-in-cljs in a shadow project (I don't know if shadow is relevant for the issue)
  • Select shadow and the app profile

Environment & Version information

CIDER version information

Include here the version string displayed when
CIDER's REPL is launched. Here's an example:

;; CIDER 0.25.0snapshot (package: 20200521.627), nREPL 0.7.0
;; Clojure 1.10.0, Java 13.0.1

Emacs version

GNU Emacs 26.3 (build 1, x86_64-apple-darwin18.5.0, NS appkit-1671.40 Version 10.14.4 (Build 18E226)) of 2019-08-30

Operating system

Mac OS 10.15.4

@dpsutton
Copy link
Contributor

dpsutton commented May 25, 2020

The simplest repro is to have a buffer with a simple (ns ) form and call clojure-find-ns.

Seems like this should be fixed in clojure-mode and perhaps also CIDER?

@bbatsov
Copy link
Member

bbatsov commented May 25, 2020

I was also thinking that probably this should be fixed in clojure-mode, e.g. cider-find-ns could return nil in such cases.

@bbatsov bbatsov added bug good first issue A simple tasks suitable for first-time contributors labels Jun 1, 2020
@vemv vemv pinned this issue Aug 18, 2023
@vemv vemv unpinned this issue Aug 23, 2023
vemv added a commit that referenced this issue Aug 23, 2023
bbatsov pushed a commit that referenced this issue Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 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