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

Trouble getting M-. (cider-find-var) to work, even though I am running cider-jack-in-clj&cljs in file beforehand #2939

Closed banjomet closed 3 years ago

banjomet commented 3 years ago

Use the template below when reporting bugs. Please, make sure that you're running the latest stable CIDER and that the problem you're reporting hasn't been reported (and potentially fixed) already.

Remove all of the placeholder text in your final report!

Expected behavior

Start off by visiting a file in https://github.com/Gonzih/cljs-electron/ I chose https://github.com/Gonzih/cljs-electron/blob/master/ui_src/ui/core.cljs and executing M-x cider-jack-in-clj&cljs M-. on 'def' in https://github.com/Gonzih/cljs-electron/blob/master/ui_src/ui/core.cljs should take me to the source code of def.

Actual behavior

It doesn't work. Instead cider-find-var (M-.) prompts "Symbol: " in the minibuffer with no prefilled suggestions. When I write in 'def' and hit return it tells me no cljs REPLs are in current session.

Steps to reproduce the problem

Clone the repository: https://github.com/Gonzih/cljs-electron/ and then try to M-. any function/variable/macro in ui_src/ui/core.cljs.

Environment & Version information

I tried updating the dependencies because someone suggested that in a totally different cljs project that would fix it.

Here it is:

 :dependencies [[org.clojure/clojure "1.10.1"]
                 [org.clojure/clojurescript "1.10.758"]
                 [figwheel "0.5.19"]
                 [figwheel-sidecar "0.5.19"]
                 [cider/piggieback "0.5.1"]
                 [reagent "0.8.1"]
                 [ring/ring-core "1.7.1"]]
  :plugins [[lein-cljsbuild "1.1.7"]
            [lein-figwheel "0.5.20"]
            [lein-cooper "1.2.2"]]

CIDER version information

;; CIDER 1.0.0snapshot (package: 20201125.1146), nREPL 0.8.3
;; Clojure 1.10.1, Java 11.0.9.1

Lein/Boot version

skip

Emacs version

27.1

Operating system

Ubuntu 20.10

banjomet commented 3 years ago

So I seem to have been trying cider-jack-in-cljs and cider-jack-in-clj but neither seem to start a cljs repl, only a clj one.

I am getting clj:cljs-electron@:32823 when I run cider-jack-in-cljs. Does the prefix "clj:" indicate it as a clojure only repl? I switched to the repl and figwheel seems to have started successfully and I see the user> prompt.

For me in my cljs project, I get cider[not connected], yet when I run (ignore-errors (cider-current-repl)) I get #<buffer *cider-repl clojure/cljs-electron:localhost:32823(clj)*>.

When I run cider-connect and it lists that repl as open, and says I could spawn a sister or whatever, I choose to proceed but cider still says it is disconnected.

Also, whenever I open a cljs or clj file in a new emacs session, I get cider[not connected] immediately, even before I have tried cider-jack-in*. I don't know what is causing it to start early, maybe clojure-lsp?

Here is my clojure/script config so far. I have been stealing parts from random github projects trying to iterate on it and trying to see what matters. The only thing I cannot figure out is how much clojurescript-mode inherits from the settings in clojure-mode. Here is a link to it.

bbatsov commented 3 years ago

Mostly likely something went wrong during the REPL initialization phase. Check the *Messages* buffer for anything looking like an error and the *nrepl-messages* buffer (in particular look there some repl-type messages) https://docs.cider.mx/cider/0.26/troubleshooting.html#debugging-the-communication-with-nrepl

banjomet commented 3 years ago

Everything seems to look fine - no obvious errors.

This is from *cider-repl cljs-electron:localhost:localhost:46347(clj)*:

;; Connected to nREPL server - nrepl://localhost:46347 CIDER
;; 1.0.0snapshot (package: 20201125.1146), nREPL 0.8.3 Clojure 1.10.1,
;; Java 11.0.9.1 Docs: (doc function-name) (find-doc part-of-name)
;; Source: (source function-name) Javadoc: (javadoc
;; java-object-or-class) Exit: <C-c C-q> Results: Stored in vars *1,
;; *2, *3, an exception in *e;
;; ======================================================================
;; If you’re new to CIDER it is highly recommended to go through its
;; user manual first. Type <M-x cider-view-manual> to view it.  In
;; case you’re seeing any warnings you should consult the manual’s
;; "Troubleshooting" section.  Here are few tips to get you started: *
;; Press <C-h m> to see a list of the keybindings available (this will
;; work in every Emacs buffer) * Press <,> to quickly invoke some REPL
;; command * Press <C-c C-z> to switch between the REPL and a Clojure
;; file * Press <M-.> to jump to the source of something (e.g. a var,
;; a Java method) * Press <C-c C-d C-d> to view the documentation for
;; something (e.g.  a var, a Java method) * Print CIDER’s refcard and
;; keep it close to your keyboard.  CIDER is super customizable - try
;; <M-x customize-group cider> to get a feel for this. If you’re
;; thirsty for knowledge you should try <M-x cider-drink-a-sip>.  If
;; you think you’ve encountered a bug (or have some suggestions for
;; improvements) use <M-x cider-report-bug> to report it.  Above all
;; else - don’t panic! In case of an emergency - procure some (hard)
;; cider and enjoy it responsibly!  You can remove this message with
;; the <M-x cider-repl-clear-help-banner> command.  You can disable it
;; from appearing on start by setting ‘cider-repl-display-help-banner’
;; to nil.
;; ======================================================================
;; Startup: /home/banjomet/bin/lein update-in :dependencies conj
;; \[nrepl\ \"0.8.3\"\] -- update-in :dependencies conj
;; \[cider/piggieback\ \"0.5.2\"\] -- update-in :plugins conj
;; \[refactor-nrepl\ \"2.5.0\"\] -- update-in :plugins conj
;; \[cider/cider-nrepl\ \"0.25.5\"\] -- repl :headless :host localhost
;; ClojureScript REPL type: figwheel
user> 

`clojure-lsp::stderr contains nothing

This is from *nrepl-messages cljs-electron:localhost:46347(clj)*

(-->
  id         "1"
  op         "clone"
  time-stamp "2020-12-09 12:39:12.776862500"
)
(<--
  id          "1"
  session     "9ebecd0d-6e9c-4d67-8167-8f66eb3b3945"
  time-stamp  "2020-12-09 12:39:12.783096892"
  new-session "03500966-3b15-43a7-ac85-a18491481464"
  status      ("done")
)
(-->
  id         "2"
  op         "clone"
  time-stamp "2020-12-09 12:39:12.798033743"
)
(<--
  id          "2"
  session     "06385c47-0e8d-44a6-a98f-6da5535d0c9a"
  time-stamp  "2020-12-09 12:39:12.800994501"
  new-session "9bdba0f8-04c9-42d6-b3a0-0f573bc22f3e"
  status      ("done")
)
(-->
  id         "3"
  op         "describe"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:12.818921375"
)
(<--
  id         "3"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:12.824604263"
  aux        (dict ...)
  ops        (dict ...)
  status     ("done")
  versions   (dict ...)
)
(-->
  id                                 "4"
  op                                 "eval"
  session                            "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp                         "2020-12-09 12:39:13.030030540"
  code                               "(clojure.core/apply clojure.core/require clojure.main/repl-r..."
  column                             1
  file                               "*cider-repl cljs-electron:localhost:46347(pending-c..."
  inhibit-cider-middleware           "true"
  line                               47
  nrepl.middleware.print/buffer-size 4096
  nrepl.middleware.print/options     (dict ...)
  nrepl.middleware.print/print       "cider.nrepl.pprint/pprint"
  nrepl.middleware.print/quota       1048576
  nrepl.middleware.print/stream?     "1"
)
(<--
  id         "4"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:13.094888686"
  value      "nil"
)
(<--
  id         "4"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:13.095211137"
  ns         "user"
)
(<--
  id         "4"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:13.095530898"
  status     ("done")
)
(-->
  id         "5"
  op         "out-subscribe"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:13.096283799"
)
(-->
  id                                 "6"
  op                                 "init-debugger"
  session                            "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp                         "2020-12-09 12:39:13.097106801"
  nrepl.middleware.print/buffer-size 4096
  nrepl.middleware.print/options     (dict ...)
  nrepl.middleware.print/print       "cider.nrepl.pprint/pprint"
  nrepl.middleware.print/quota       1048576
  nrepl.middleware.print/stream?     "1"
)
(-->
  id         "7"
  op         "eval"
  session    "9bdba0f8-04c9-42d6-b3a0-0f573bc22f3e"
  time-stamp "2020-12-09 12:39:13.098036628"
  code       "(require 'cljs.core)"
)
(<--
  id         "6"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:14.268902308"
  status     ("done")
)
(<--
  id            "5"
  session       "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp    "2020-12-09 12:39:15.927656117"
  out-subscribe "03500966-3b15-43a7-ac85-a18491481464"
  status        ("done")
)
(<--
  id         "7"
  session    "9bdba0f8-04c9-42d6-b3a0-0f573bc22f3e"
  time-stamp "2020-12-09 12:39:15.984648116"
  ns         "user"
  value      "nil"
)
(<--
  id         "7"
  session    "9bdba0f8-04c9-42d6-b3a0-0f573bc22f3e"
  time-stamp "2020-12-09 12:39:15.985851962"
  status     ("done")
)
(-->
  id         "8"
  op         "eval"
  session    "9bdba0f8-04c9-42d6-b3a0-0f573bc22f3e"
  time-stamp "2020-12-09 12:39:16.003370524"
  code       "(require 'cider.piggieback)"
)
(<--
  id         "8"
  session    "9bdba0f8-04c9-42d6-b3a0-0f573bc22f3e"
  time-stamp "2020-12-09 12:39:16.008245521"
  ns         "user"
  value      "nil"
)
(<--
  id         "8"
  session    "9bdba0f8-04c9-42d6-b3a0-0f573bc22f3e"
  time-stamp "2020-12-09 12:39:16.009199294"
  status     ("done")
)
(-->
  id         "9"
  op         "eval"
  session    "9bdba0f8-04c9-42d6-b3a0-0f573bc22f3e"
  time-stamp "2020-12-09 12:39:16.024547351"
  code       "(require 'figwheel-sidecar.repl)"
)
(<--
  id                 "7"
  session            "9bdba0f8-04c9-42d6-b3a0-0f573bc22f3e"
  time-stamp         "2020-12-09 12:39:16.264800419"
  changed-namespaces (dict ...)
  repl-type          "clj"
  status             ("state")
)
(<--
  id                 "8"
  session            "9bdba0f8-04c9-42d6-b3a0-0f573bc22f3e"
  time-stamp         "2020-12-09 12:39:16.265392536"
  changed-namespaces (dict)
  repl-type          "clj"
  status             ("state")
)
(<--
  id         "9"
  session    "9bdba0f8-04c9-42d6-b3a0-0f573bc22f3e"
  time-stamp "2020-12-09 12:39:24.305262815"
  ns         "user"
  value      "nil"
)
(<--
  id         "9"
  session    "9bdba0f8-04c9-42d6-b3a0-0f573bc22f3e"
  time-stamp "2020-12-09 12:39:24.346495809"
  status     ("done")
)
(<--
  id                 "9"
  session            "9bdba0f8-04c9-42d6-b3a0-0f573bc22f3e"
  time-stamp         "2020-12-09 12:39:24.346827133"
  changed-namespaces (dict)
  repl-type          "clj"
  status             ("state")
)
(-->
  id         "10"
  op         "eval"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:24.363695803"
  code       "(do (require 'figwheel-sidecar.repl-api) (figwheel-sidecar.r..."
  ns         "user"
)
(-->
  id               "11"
  op               "version"
  session          "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp       "2020-12-09 12:39:24.370964724"
  debug            "false"
  prefix-rewriting "false"
)
(<--
  id         "11"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:24.373839601"
  status     ("done")
  version    "2.5.0"
)
(-->
  id               "12"
  op               "version"
  session          "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp       "2020-12-09 12:39:24.400553839"
  debug            "false"
  prefix-rewriting "false"
)
(<--
  id         "12"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:24.402977731"
  status     ("done")
  version    "2.5.0"
)
(-->
  id               "13"
  op               "artifact-list"
  session          "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp       "2020-12-09 12:39:24.421455638"
  debug            "false"
  force            "false"
  prefix-rewriting "false"
)
(<--
  id         "13"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:26.159830063"
  artifacts  ("_7696122/clojure-poloniex" ...)
  status     ("done")
)
(<--
  id         "10"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:27.665933860"
  out        "Figwheel: Starting server at http://0.0.0.0:3449
"
)
(<--
  id         "10"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:27.689021135"
  out        "Figwheel: Watching build - frontend-dev
"
)
(<--
  id         "10"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:27.690008724"
  out        "Figwheel: Cleaning build - frontend-dev
"
)
(<--
  id         "10"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:27.690975297"
  out        "Compiling build :frontend-dev to "resources/public/js/ui-cor..."
)
(<--
  id         "10"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:28.214503205"
  out        "Successfully compiled build :frontend-dev to "resources..."
)
(<--
  id         "10"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:28.241961454"
  out        "Figwheel: Starting CSS Watcher for paths  ["resources/public..."
)
(<--
  id         "10"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:28.242567348"
  out        "Launching ClojureScript REPL for build: frontend-dev
"
)
(<--
  id         "10"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:28.242968964"
  out        "Figwheel Controls:
          (stop-autobuild)               ..."
)
(<--
  id         "10"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:28.243721089"
  out        "(doc function-name-here)
    Exit: :cljs/quit
 Results: Stor..."
)
(<--
  id         "10"
  session    "03500966-3b15-43a7-ac85-a18491481464"
  time-stamp "2020-12-09 12:39:28.244176751"
  out        "Prompt will show when Figwheel connects to your application
"
)

*Messages* contains nothing relevant:

LSP :: Connected to [clojure-lsp:58907 status:starting].
File mode specification error: (void-function enable)
[nREPL] Starting server via /home/banjomet/bin/lein update-in :dependencies conj \[nrepl\ \"0.8.3\"\] -- update-in :dependencies conj \[cider/piggieback\ \"0.5.2\"\] -- update-in :plugins conj \[refactor-nrepl\ \"2.5.0\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.25.5\"\] -- repl :headless :host localhost
[nREPL] server started on 46347
[nREPL] Establishing direct connection to localhost:46347 ...
[nREPL] Direct connection to localhost:46347 established
[nREPL] Establishing direct connection to localhost:46347 ...
[nREPL] Direct connection to localhost:46347 established
LSP :: clojure-lsp:58907 initialized successfully
There are 1077 files in folder /home/banjomet/src/startups/cljs-electron so watching the repo may slow Emacs down.
Do you want to watch all files in /home/banjomet/src/startups/cljs-electron? (y or n) y
LSP :: You can configure this warning with the `lsp-enable-file-watchers' and `lsp-file-watch-threshold' variables
Quit [2 times]
Mark set [2 times]
Saved text until "gwheel connects to your application
"
)
"
Quit
command-execute: Buffer is read-only: #<buffer *nrepl-messages cljs-electron:localhost:46347(clj)*>
Quit
Mark set [2 times]
fill-delete-newlines: Text is read-only
Mark set [2 times]
End of buffer.  Type M-x View-quit to quit viewing.
s is undefined [2 times]
End of buffer.  Type M-x View-quit to quit viewing. [2 times]
Quit
bbatsov commented 3 years ago

I don't see something like:

(<--
  id                 "7"
  session            "9bdba0f8-04c9-42d6-b3a0-0f573bc22f3e"
  time-stamp         "2020-12-09 12:39:16.264800419"
  changed-namespaces (dict ...)
  repl-type          "clj"
  status             ("state")
)

That would indicate the successful upgrade of the REPL to ClojureScript, so I assume that's the problem, but I'm not sure what's causing it. You can try disabling the repl type detection and setting it manually https://docs.cider.mx/cider/0.26/repl/configuration.html#repl-type-detection

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!

stale[bot] commented 3 years ago

This issues been automatically closed due to lack of activity. Feel free to re-open it if you ever come back to it.