Fork me on GitHub
#cursive
<
2022-08-08
>
helios07:08:51

I am not able to see the actual error message for a test failure, what's up? FWIW in this project i've never been able to 😞 There's no way of showing the difference

cfleming08:08:28

Hmm, I’m not sure. Is this a project I can look at?

cfleming08:08:44

Which version of Cursive are you on?

helios08:08:00

Unfortunately not. Latest intellij and EAP cursive

helios08:08:30

But it has been like this for a while now (i just wasn't writing too many tests 😂)

helios08:08:53

So even though they are normal clojure tests, there's a few layers in between that maybe hide it from cursive

imre08:08:06

I guess a minimal repro case could help

👍 1
cfleming09:08:07

That would definitely help.

danm08:08:43

Is there any plan to work on this: https://github.com/cursive-ide/cursive/issues/1929 at some point? I can see that ticket was raised in 2018, and has had no comments or similar on it since. We've just started running REPLs via bazel, because we're also using it for all our builds etc, and at the moment we're getting output appear in the terminal that the REPL itself is running in, not in the IntelliJ window that is connected to it. We also sometimes connect REPLs to our running system (K8s pods in AWS) to debug it, and hit the same problem there - some of the output we want ends up going to the pod log rather than the IntelliJ window

cfleming09:08:35

You might actually be able to do that these days with no change to Cursive, using the .nrepl.edn config file, see https://cursive-ide.com/userguide/repl.html#configuring-middleware-for-nrepl-repls.

cfleming09:08:48

If that won’t work for whatever reason, let me know and I’ll look at that issue more closely.

cfleming09:08:11

Just to be clear, I think you should be able to use that config file to configure the CIDER middleware for your REPL.

danm11:08:43

Ooh, interesting. Will give it a whirl, ta 😄

danm16:08:38

Hmm, so I've gone digging, and we're already launching the REPL with all the relevant middleware running

danm16:08:51

Anyone who is already using Emacs+CIDER gets their output as expected

danm16:08:21

But I don't in Cursive

danm16:08:30

But I have to admit I don't understand why, if the REPL server is being loaded with that middleware running, it would not send the output back to the connected Cursive REPL session

danm17:08:07

Ahha, asking in #nrepl and I got this https://clojurians.slack.com/archives/C17JYSA3H/p1659976888613829 Looks like I need to work out how to get the nREPL client from within Cursive, and send the out-subscribe message to it. But this is something that is lower level than the REPL I'm used to interacting with, I think. Need to dig more. If I can do it in our user space that'll do for now, though if Cursive would do it automatically if the middleware was loaded, like Emacs does, that would be 🎉

Ivar Refsdal18:08:10

Cross post from #nrepl as well, this gist has solved this issue for me (and other people here as well): https://gist.github.com/daviesian/4517859 nrepl issue: https://github.com/nrepl/nrepl/issues/119

danm19:08:35

I've fixed it with the following, which runs on REPL load because it's in our auto-loaded user ns:

(ns user
  (:require [nrepl.core :as nrepl]
            [nrepl.misc :refer [uuid]])
  (:import ( ConnectException)))

(try
  (let [client (-> (nrepl/connect {:host "localhost" :port 4005})
                   (nrepl/client 1000))]
    (nrepl/message client {:id (uuid) :op "out-subscribe"}))
  (catch ConnectException _)) ; Don't care if it fails, we're probably not a remote REPL

danm19:08:17

Obviously it's a bit hacky, and you'd probably want something cleaner in Cursive proper, if it ran on every REPL start. Probably using the hostname/port provided in the config (I just know ours is always localhost with port forwards, and 4005), and actually checking if the middleware is loaded, like CIDER does, rather than just a try...catch

cfleming22:08:35

Ok, thanks for all that investigation! I’ll look at robustifying Cursive there.

cfleming22:08:02

Is it a reasonable assumption that if that middleware is present then the client will always want to subscribe? I’m thinking probably yes.

danm05:08:55

That certainly seems to be the assumption that CIDER makes

cfleming07:08:43

The cider-redirect-server-output-to-repl bit looks like a config flag to me - I’ll check that.

danm09:08:19

https://github.com/clojure-emacs/cider/blob/9577dbbdae8cffe023442427b97f963b4447983a/cider-connection.el#L329-L330 is where it's called, and https://github.com/clojure-emacs/cider/blob/9577dbbdae8cffe023442427b97f963b4447983a/cider-connection.el#L48-L55 is the definition. So you're definitely right that it's a config flag. I don't know where you'd see any default values. Certainly everyone in the team here who uses CIDER (or vim-fireplace, which also makes use of cider-nrepl extensions) has said "Oh, that Just Works for me", so either it's default true or everyone has cargo culted someone else's config file and never looked into what that option does 😉

cfleming22:08:56

Which sounds eminently possible 🙂

cfleming22:08:20

However dpsutton confirmed over in #nrepl that it’s an opt-out flag, so on by default.