nrepl

https://github.com/nrepl/nrepl || https://nrepl.org
manas_marthi 2018-11-02T04:23:43.050100Z

Tried with a clean .m2 folder and profiles clj matching yours on a Ubuntu vm..

manas_marthi 2018-11-02T04:25:39.052900Z

lein nrepl was responding to things like 'a4 or (println 45) but quit or ctrl D did not work

manas_marthi 2018-11-02T04:26:24.054Z

lein repl worked, but it was giving the same namespace error

manas_marthi 2018-11-02T04:31:15.058300Z

I have not tried using nrepl as server and connect to it from cider in my spacemacs. I will try that as well..

manas_marthi 2018-11-02T04:41:53.062400Z

On an older project lein repl produced same namespace error. I commented lein-nrepl 0.3.0 in profiles.clj. It started working fine. It was showing what version of nrepl and reply it was using. Looks like lein-nrepl 0.3.0 is unable to play nicely with lein or reply

manas_marthi 2018-11-02T04:51:06.070800Z

Besides, I switched back to lein-nrepl 0.2.0. and tried lein repl. The server page in http://nrepl.xyz says lein repl will start nrepl if the new nrepl 0.4.5 is on the dependencies list. But the reply prompt is still showing nrepl 0.2.12. Should the doc be changed to lein nrepl?

manas_marthi 2018-11-02T04:57:37.072600Z

Can't recall where did I see the steps to connect to nrepl server from cider in emacs 🙂

bozhidar 2018-11-02T06:04:41.078100Z

Well, lein repl will work, but it will obviously start a legacy server unless you’ve built lein from source.

bozhidar 2018-11-02T06:05:40.079100Z

I have a feeling that the problem is that adding a dep to the newer reply simply messes up the reply dep that comes with lein, but I’m completely puzzled why this works for me and not for you.

bozhidar 2018-11-02T06:29:55.079600Z

@dominicm can you test lein nrepl when you’ve got the chance? I’m curious if it will work for you.

dominicm 2018-11-02T06:33:39.080200Z

I'll do it when I'm at a keyboard, about 2 hours?

bozhidar 2018-11-02T06:34:24.080700Z

Whenever you can. It’s not urgent. I just don’t like unsolved mysteries. 🙂

1
dominicm 2018-11-02T08:01:42.081Z

Me neither

dominicm 2018-11-02T08:03:15.081200Z

hmph.

Exception in thread "main" java.lang.ClassNotFoundException: leiningen.nrepl, compiling:(/tmp/form-init391929446154209103.clj:1:72)

dominicm 2018-11-02T08:04:13.081600Z

I think the sample profiles.clj is invalid, also:

{:user
 {:dependencies [[cider/cider-nrepl "0.18.0"]]}
 {:plugins [[nrepl/lein-nrepl "0.2.0"]]}}

dominicm 2018-11-02T08:04:32.081900Z

That's "things" keys in the top-level map.

dominicm 2018-11-02T08:05:15.082400Z

Oh, ignore my exception, it's because i had an old version in the project.

dominicm 2018-11-02T08:06:10.082800Z

Okay. Works. REPL-y loads up for me. 🙂

dominicm 2018-11-02T08:06:23.083100Z

Unless there's a specific invocation I need to test.

dominicm 2018-11-02T08:06:38.083500Z

Oh, I need to test Ctrl-D, I remember 🙂

bozhidar 2018-11-02T08:06:39.083600Z

Nope, nothing special.

dominicm 2018-11-02T08:06:53.084Z

Ctrl-D gives me "Bye for now!" then hangs.

dominicm 2018-11-02T08:06:59.084300Z

Ctrl-C finishes it off.

bozhidar 2018-11-02T08:07:31.084700Z

That’s weird. It should hang only with :headless option.

bozhidar 2018-11-02T08:07:50.085200Z

For it me it works just fine. It’s so frustrating when something is 5 lines of code and there are still issues with it. 😄

bozhidar 2018-11-02T08:09:18.085800Z

I stand corrected - 6 lines.

dominicm 2018-11-02T08:09:32.086300Z

Should be easy to figure out what's keeping it up, one sec

bozhidar 2018-11-02T08:09:49.086600Z

So, it should not hang unless :block and :headless are both true.

dominicm 2018-11-02T08:10:13.086900Z

or a thread is keeping the jvm up 🙂

dominicm 2018-11-02T08:12:15.087200Z

"clojure-agent-send-off-pool-1" #10 prio=5 os_prio=0 tid=0x00007f3f00a03000 nid=0x2112 waiting on condition [0x00007f3ee9e16000] there's a few of these kicking about

dominicm 2018-11-02T08:14:30.087500Z

main is waiting on something :thinking_face:

dominicm 2018-11-02T08:14:46.087700Z

"main" #1 prio=5 os_prio=0 tid=0x00007f3f0000a800 nid=0x20fd in Object.wait() [0x00007f3f09449000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x000000076cf15e80> (a java.lang.Thread)
        at java.lang.Thread.join(Thread.java:1252)
        - locked <0x000000076cf15e80> (a java.lang.Thread)
        at java.lang.Thread.join(Thread.java:1326)
        at com.hypirion.io.Pipe.join(Pipe.java:120)
        at leiningen.core.eval$sh.invokeStatic(eval.clj:191)
        at leiningen.core.eval$sh.doInvoke(eval.clj:173)

dominicm 2018-11-02T08:15:06.088200Z

Maybe I've dumped the threads for the outer JVM?

bozhidar 2018-11-02T08:15:29.088600Z

No idea. Reply and nREPL doesn’t use agents at all.

bozhidar 2018-11-02T08:15:42.088900Z

That’s why I’m really puzzled how this happens.

bozhidar 2018-11-02T08:24:22.089400Z

Btw, after a few days of experimentation I’m finally happy with the state of https://github.com/nrepl/nrepl/pull/66 and I just merged it.

dominicm 2018-11-02T08:33:41.090100Z

Neat, I can do that in fireplace/replant too 🙂

bozhidar 2018-11-02T08:36:03.091800Z

Originally I had added some nREPL env variables as well, but I opted to remove them as they made more complex the elegant map merging code (now you just have a global, local and command-line maps that are simply merged together in this order) and opened the question what exactly should be the precedence of the env vars.

bozhidar 2018-11-02T08:36:23.092200Z

(higher or lower than global config & local config)

bozhidar 2018-11-02T08:36:31.092600Z

In the end I decided that less is more. 🙂

dominicm 2018-11-02T08:36:54.093100Z

Fun fact, if I add a println after (client), it isn't called when I hit "Ctrl-D"

bozhidar 2018-11-02T08:37:33.093300Z

Now I’m completely puzzled.

dominicm 2018-11-02T08:39:56.093600Z

(quit) has the same behaviour.

dominicm 2018-11-02T08:49:15.094900Z

Actually, I don't see any println from code around (client), so *out* must have an override.

dominicm 2018-11-02T08:51:21.095100Z

oh, I fixed it. Somehow.

dominicm 2018-11-02T08:52:40.095400Z

Okay. It's not happening anymore. I can't explain why.

dominicm 2018-11-02T08:53:28.095800Z

Yes I can. When I run it in aero it hangs, when I run it in lein-nrepl, it doesn't.

dominicm 2018-11-02T08:56:44.096100Z

I can also reproduce in bidi.

dominicm 2018-11-02T08:56:53.096400Z

@bozhidar what project(s) did you test on?

bozhidar 2018-11-02T09:08:02.096800Z

In lein-nrepl and without a project.

dominicm 2018-11-02T09:08:25.097200Z

I can't run it without a project, I get:

❯ lein nrepl
Couldn't find project.clj, which is needed for nrepl

bozhidar 2018-11-02T09:09:02.097700Z

OK, just tested it another project. It hangs for me as well. Damn, I hate lein at this point…

dominicm 2018-11-02T09:09:23.098100Z

😄 so much machinery. I get what Cognitect say about it.

bozhidar 2018-11-02T09:09:36.098500Z

Well. lein really overdid it.

bozhidar 2018-11-02T09:09:54.099Z

When I was looking at the code for lein repl I was shocked how much was going on there.

dominicm 2018-11-02T09:10:07.099500Z

I just loaded it up 😄

bozhidar 2018-11-02T09:10:08.099600Z

boot repl, on the other hand, is 20 lines.

bozhidar 2018-11-02T09:10:35.100100Z

I just borrowed some code from boot repl for lein-nrepl but I guess that’s not enough.

bozhidar 2018-11-02T09:10:54.100600Z

Anyways, the repl works fine you just have kill it brute-force at the end which is not that bad IMO.

dominicm 2018-11-02T09:11:40.100900Z

https://github.com/technomancy/leiningen/blob/454c3dc640f4b3507b13154bad2ee8ff91d702c9/src/leiningen/repl.clj#L168 I can't see where handle is coming from.

dominicm 2018-11-02T09:11:47.101200Z

I wonder if this is relevant though

dominicm 2018-11-02T09:12:08.101500Z

https://github.com/technomancy/leiningen/blob/454c3dc640f4b3507b13154bad2ee8ff91d702c9/src/leiningen/repl.clj#L217 ah, they force System/exit afterwards. Ouch.

bozhidar 2018-11-02T09:13:31.102100Z

Yeah, I think you found what we were looking for.

bozhidar 2018-11-02T09:13:43.102500Z

Looks ugly as hell, but probably it’s needed.

dominicm 2018-11-02T09:14:00.102800Z

Apparently not. I just tested, with no luck.

bozhidar 2018-11-02T09:15:18.103200Z

I never used trampoline, but it seems the regular client code is here https://github.com/technomancy/leiningen/blob/454c3dc640f4b3507b13154bad2ee8ff91d702c9/src/leiningen/repl.clj#L258

bozhidar 2018-11-02T09:15:25.103600Z

I don’t see anything magical though.

bozhidar 2018-11-02T09:16:19.104Z

Ah, no. That’s what’s invoked in lein repl :connect. My bad.

bozhidar 2018-11-02T09:16:26.104300Z

Seems you had found the right code.

dominicm 2018-11-02T09:17:32.104600Z

Doesn't look like lein install is doing the right thing for me 😞

bozhidar 2018-11-02T09:17:48.104800Z

It does it for me.

bozhidar 2018-11-02T09:17:59.105200Z

Just make sure you adjust your profile accordingly.

bozhidar 2018-11-02T09:18:10.105400Z

And the inner dep of the project.

dominicm 2018-11-02T09:18:46.106Z

OH

dominicm 2018-11-02T09:18:48.106300Z

That would do it

dominicm 2018-11-02T09:19:11.106500Z

Weird how it worked some of the time

dominicm 2018-11-02T09:25:13.106800Z

Okay, you're right, System/exit worked

bozhidar 2018-11-02T09:25:34.107Z

It always works. 😉

1
bozhidar 2018-11-02T09:26:12.107600Z

Well, I guess you deserve the credit for this, so you can commit the fix directly.

1
dominicm 2018-11-02T09:27:54.108100Z

Done 🙂

bozhidar 2018-11-02T14:12:06.108700Z

Thanks!

bozhidar 2018-11-02T14:12:38.109300Z

I’ve cut 0.3.1, so I guess @manas.marthi can check it out.

manas_marthi 2018-11-02T15:07:12.110600Z

hi @bozhidar , jar downloaded. no luck yet. I will try on my home laptop later this evening. The only difference is I am using office laptop on windows 10 behind proxy & artifactory.

manas_marthi 2018-11-02T15:07:17.110800Z

REPL server started on port 59724 on host localhost - <nrepl://localhost:59724>
REPL-y 0.4.2, nREPL 0.4.5
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_181-b13
        Exit: Control+D or (exit) or (quit)
    Commands: (user/help)
        Docs: (doc function-name-here)
              (find-doc "part-of-name-here")
Find by Name: (find-name "part-of-name-here")
      Source: (source function-name-here)
     Javadoc: (javadoc java-object-or-class-here)
    Examples from <http://clojuredocs.org|clojuredocs.org>: [clojuredocs or cdoc]
              (user/clojuredocs name-here)
              (user/clojuredocs "ns-here" "name-here")
WARNING: cat already refers to: #'clojure.core/cat in namespace: net.cgrand.parsley.fold, being replaced by: #'net.cgrand.parsley.fold/cat
user=&gt; (def x 10)
^D
quit

Terminate batch job (Y/N)? y

manas_marthi 2018-11-02T15:08:00.111Z

C:\clojureprojects\201812\archboard&gt;lein repl
nREPL server started on port 59754 on host 127.0.0.1 - <nrepl://127.0.0.1:59754>
Exception No namespace: reply.eval-modes.nrepl found  clojure.core/the-ns (core.clj:4032)
CompilerException java.lang.ClassNotFoundException: nrepl.core, compiling:(C:\Users\mman\AppData\Local\Temp\form-init8829266633462961081.clj:1:82)
#object[clojure.lang.Namespace 0x4a439316 "user"]
Error loading namespace; falling back to user
nil
user=&gt;

manas_marthi 2018-11-02T15:09:57.112Z

I will try headless repl and connect from spacemacs

manas_marthi 2018-11-02T15:10:07.112400Z

I did not try that option yet

manas_marthi 2018-11-02T15:11:00.113Z

looks like lein nrepl :headless is not the right command

manas_marthi 2018-11-02T15:19:04.114200Z

besides lein nrepl made my cpu fan run loudly.

manas_marthi 2018-11-02T15:19:14.114500Z

this is a blank project. I have just opened a repl

manas_marthi 2018-11-02T15:19:44.115200Z

I am not liking being the messenger with bad news 😞

manas_marthi 2018-11-02T15:30:46.116100Z

Qualys cloud agent could be messing with the jvm. It keeps pumping pings to open ports

bozhidar 2018-11-02T17:07:20.116500Z

It’s lein nrepl :headless true

bozhidar 2018-11-02T17:07:43.116900Z

It was easier for me to have all the args be key/value pairs. 🙂

bozhidar 2018-11-02T17:08:27.117500Z

I really wonder if those problems aren’t somewhat related to Windows, but you said you had them on Linux as well.

bozhidar 2018-11-02T17:08:54.118100Z

For me after we fixed the hang lein nrepl works perfectly and it seems that’s the case for @dominicm as well.

bozhidar 2018-11-02T17:09:26.118600Z

Alternatively you can build lein 2.8.2 from source and use it instead.

bozhidar 2018-11-02T17:09:58.119300Z

It’s really a pity they haven’t cut a release so far.

manas_marthi 2018-11-02T20:45:58.119700Z

I tried lein nrepl :headless true :middleware "['cider.nrepl/cider-middleware]" and then connected from spacemacs

manas_marthi 2018-11-02T20:48:09.120100Z

It is connecting fine except

manas_marthi 2018-11-02T20:48:12.120300Z

a warning

manas_marthi 2018-11-02T20:49:08.121300Z

clj-refactor refactor-nrepl are out of sync. their versions are 2.4.0 (package 20180826.2149) and n/a, respectively.

dominicm 2018-11-02T23:06:20.122200Z

Makes sense, you need to add the refactor middleware too 🙂