clojure-emacs/sayid

How to debug "Sayid didn't respond. Is it loaded?" ?

mattiasw2 opened this issue · 10 comments

Sayid used to work, but when I needed it for a new project, C-c stp just says "Sayid didn't respond. Is it loaded?"

Any pointers?

bpiel commented

@mattiasw2 do you have sayid loaded as a plugin either in your profiles.clj or project.clj?

Yes, added [com.billpiel/sayid "0.0.15"] to project.clj, and I use cider, so the rest is there. It has been working a few weeks ago.

I was hoping for an answer like "Look in the Message window, or call the elisp function YYYY, or clojure function XXXX."

bpiel commented

@mattiasw2

I always ask to make sure that sayid is loaded as a plugin (not a dependency), because that's usually the issue. But, if that's all in order, you can try the following.

Here's how I think about the debugging process. The issue is likely with one of these:

  1. sayid library being included as a dependency
  2. sayid nrepl middleware registered
  3. sayid.el installed in emacs

You're definitely ok with #3.

To test #1:
From the clj repl, run this to make sure the dependency is loaded:

user> (require '[com.billpiel.sayid.core :as sd])
nil
user> sd/version
"0.0.15"

If that works, then the library is available from clojure and the issue is likely with the nrepl middleware (#2).

From emacs, you can try this, although it's currently erroring for me (curious to see if it does the same for you):

M-x sayid-version

Please let me know what you get.

Running this elisp performs the same test. It effectively pings the sayid nrepl middleware:

(nrepl-dict-get (nrepl-send-sync-request (list "op" "sayid-version")
                                         (cider-current-connection))
                "value")

If the middleware is working, then you should get back: "0.0.15"

Please let me know what happens and we can go from there.

thanks

You are right, I didn't use it as plugin, I misinterpreted the statement "For the full emacs+cider experience, you'll want to include Sayid as a plug-in, ". I thought it was a 2nd alternative.

Hi, @bpiel ,

I'm experimenting the same problem.
I'm using Spacemacs, with @practicalli-john's setup.

This what I have done so far.

  1. I start a REPL session from the command line, from my project root:

% clj -M:lib/sayid:repl/refactor

(I have also tried % clj -M:repl/refactor:lib/sayid.)

Relevant code from my ~/.clojure/deps.edn below:

 :lib/sayid
  {:extra-deps {com.billpiel/sayid {:mvn/version "0.1.0"}}}

...

:repl/refactor
  {:extra-deps {nrepl/nrepl                   {:mvn/version "1.0.0"}
                cider/cider-nrepl             {:mvn/version "0.30.0"}
                refactor-nrepl/refactor-nrepl {:mvn/version "3.6.0"}}
   :main-opts  ["-m" "nrepl.cmdline"
                "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"
                "--interactive"]}
  1. I successfully connect to the REPL from Emacs/Spacemacs.

  2. In the REPL, I run

user=> (require '[com.billpiel.sayid.core :as sd])
nil
user=> sd/version
"0.1.0"
  1. I execute Emacs'/Spacemacs' command sayid-version.

I get clj=nil el=0.1.0

So far, so good.
(UPDATE: This is wrong. See below.)

  1. However, when I execute sayid-load-enable-clear, I get the dreaded "Sayid didn't respond. Is it loaded?"

Cider-debug seems to work fine.
However, I cannot load Sayid.

What am I missing?

BTW: I'm using @practicalli-john's setup and the following project deps.edn.

https://github.com/allentiak/scramble/blob/8993513ad5f68a8487e83367df318bfdf9ea5978/deps.edn


UPDATE
I have also tried using the same alias for everything, with no avail.

https://practical.li/spacemacs/debug-clojure/sayid-debug/#cider-connect

bpiel commented

Hi @allentiak

The first clue of a problem is actually this line you pasted: clj=nil el=0.1.0
Specifically, the nil. If the setup were ok, it would show a valid matching version instead, ie 0.1.0

My guess is that the problem is that you're not loading the middleware.

For example, some lines from my deps.edn:

                :main-opts ["-m" "nrepl.cmdline"
                            "--middleware"
                            "[cider.nrepl/cider-middleware com.billpiel.sayid.nrepl-middleware/wrap-sayid]"
                            "--port" "4000"]

Note the com.billpiel.sayid.nrepl-middleware/wrap-sayid portion.

If you try that and it doesn't work, let me know.

@bpiel

Thanks so much for the quick and precise reply!

Adding the com.billpiel.sayid.nrepl-middleware/wrap-sayid did the trick!

PS: This is the fixed alias:

  :repl/sayid-refactor
  {:extra-deps {nrepl/nrepl                   {:mvn/version "1.0.0"}
                cider/cider-nrepl             {:mvn/version "0.28.7"}
                com.billpiel/sayid {:mvn/version "0.1.0"}
                refactor-nrepl/refactor-nrepl {:mvn/version "3.6.0"}}
   :main-opts  ["-m" "nrepl.cmdline"
                "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware, com.billpiel.sayid.nrepl-middleware/wrap-sayid]"
                "--interactive"]}
bpiel commented

@allentiak No problem! I happened to just sit down to writing some clojure, so it was well timed. Also, I didn't know about the sayid practical.li page you linked to, so thanks for that.

It seems I should remove the :lib/sayid alias as the library does not have value without the middleware

I assume the :repl/cider-debug and :repl/cider-debug-refactor aliases are okay.

Running a repl in the command line with one of these aliases and then using cider-connect seems to be the simplest approach

https://practical.li/spacemacs/debug-clojure/sayid-debug/

It's not as simple when using cider-jack-in workflow as the jack-in config :main-opts takes precedence

It is technically possible to disable the cider dependencies that are injected into the clojure command when using cider-jack-in. However this requires several Emacs variables to be set to nil and a correctly constructed alias to be used instead, ensuring version of all libraries work together (lees of an issue recently). This could all be done on a .dir-locals.el file, although I believe it simpler to run the repl in a terminal and use cider-connect

I've created a PR to update practicalli/clojure-deps-edn aliases with several alias variations that include the sayid middleware when runing a repl (basic and with rebel)
practicalli/clojure-cli-config#63