Tried with a clean .m2 folder and profiles clj matching yours on a Ubuntu vm..
lein nrepl
was responding to things like 'a4
or (println 45)
but quit
or ctrl D
did not work
lein repl
worked, but it was giving the same namespace error
I have not tried using nrepl as server and connect to it from cider in my spacemacs. I will try that as well..
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
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
?
Can't recall where did I see the steps to connect to nrepl server from cider in emacs 🙂
Well, lein repl
will work, but it will obviously start a legacy server unless you’ve built lein
from source.
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.
@dominicm can you test lein nrepl
when you’ve got the chance? I’m curious if it will work for you.
I'll do it when I'm at a keyboard, about 2 hours?
Whenever you can. It’s not urgent. I just don’t like unsolved mysteries. 🙂
Me neither
hmph.
Exception in thread "main" java.lang.ClassNotFoundException: leiningen.nrepl, compiling:(/tmp/form-init391929446154209103.clj:1:72)
I think the sample profiles.clj is invalid, also:
{:user
{:dependencies [[cider/cider-nrepl "0.18.0"]]}
{:plugins [[nrepl/lein-nrepl "0.2.0"]]}}
That's "things" keys in the top-level map.
Oh, ignore my exception, it's because i had an old version in the project.
Okay. Works. REPL-y loads up for me. 🙂
Unless there's a specific invocation I need to test.
Oh, I need to test Ctrl-D, I remember 🙂
Nope, nothing special.
Ctrl-D gives me "Bye for now!" then hangs.
Ctrl-C finishes it off.
That’s weird. It should hang only with :headless
option.
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. 😄
https://github.com/nrepl/lein-nrepl/blob/master/src/leiningen/nrepl.clj#L53
I stand corrected - 6 lines.
Should be easy to figure out what's keeping it up, one sec
So, it should not hang unless :block and :headless are both true.
or a thread is keeping the jvm up 🙂
"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
main is waiting on something :thinking_face:
"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)
Maybe I've dumped the threads for the outer JVM?
No idea. Reply and nREPL doesn’t use agents at all.
That’s why I’m really puzzled how this happens.
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.
Neat, I can do that in fireplace/replant too 🙂
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.
(higher or lower than global config & local config)
In the end I decided that less is more. 🙂
Fun fact, if I add a println
after (client)
, it isn't called when I hit "Ctrl-D"
Now I’m completely puzzled.
(quit)
has the same behaviour.
Actually, I don't see any println from code around (client)
, so *out*
must have an override.
oh, I fixed it. Somehow.
Okay. It's not happening anymore. I can't explain why.
Yes I can. When I run it in aero it hangs, when I run it in lein-nrepl
, it doesn't.
I can also reproduce in bidi.
@bozhidar what project(s) did you test on?
In lein-nrepl
and without a project.
I can't run it without a project, I get:
❯ lein nrepl
Couldn't find project.clj, which is needed for nrepl
OK, just tested it another project. It hangs for me as well. Damn, I hate lein at this point…
😄 so much machinery. I get what Cognitect say about it.
Well. lein really overdid it.
When I was looking at the code for lein repl
I was shocked how much was going on there.
I just loaded it up 😄
boot repl
, on the other hand, is 20 lines.
I just borrowed some code from boot repl
for lein-nrepl
but I guess that’s not enough.
Anyways, the repl works fine you just have kill it brute-force at the end which is not that bad IMO.
https://github.com/technomancy/leiningen/blob/454c3dc640f4b3507b13154bad2ee8ff91d702c9/src/leiningen/repl.clj#L168 I can't see where handle
is coming from.
I wonder if this is relevant though
https://github.com/technomancy/leiningen/blob/454c3dc640f4b3507b13154bad2ee8ff91d702c9/src/leiningen/repl.clj#L217 ah, they force System/exit afterwards. Ouch.
Yeah, I think you found what we were looking for.
Looks ugly as hell, but probably it’s needed.
Apparently not. I just tested, with no luck.
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
I don’t see anything magical though.
Ah, no. That’s what’s invoked in lein repl :connect
. My bad.
Seems you had found the right code.
Doesn't look like lein install
is doing the right thing for me 😞
It does it for me.
Just make sure you adjust your profile accordingly.
And the inner dep of the project.
https://github.com/nrepl/lein-nrepl/blob/master/src/leiningen/nrepl.clj#L18
OH
That would do it
Weird how it worked some of the time
Okay, you're right, System/exit
worked
It always works. 😉
Well, I guess you deserve the credit for this, so you can commit the fix directly.
Done 🙂
Thanks!
I’ve cut 0.3.1, so I guess @manas.marthi can check it out.
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.
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=> (def x 10)
^D
quit
Terminate batch job (Y/N)? y
C:\clojureprojects\201812\archboard>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=>
I will try headless repl and connect from spacemacs
I did not try that option yet
looks like lein nrepl :headless
is not the right command
besides lein nrepl
made my cpu fan run loudly.
this is a blank project. I have just opened a repl
I am not liking being the messenger with bad news 😞
Qualys cloud agent could be messing with the jvm. It keeps pumping pings to open ports
It’s lein nrepl :headless true
It was easier for me to have all the args be key/value pairs. 🙂
I really wonder if those problems aren’t somewhat related to Windows, but you said you had them on Linux as well.
For me after we fixed the hang lein nrepl
works perfectly and it seems that’s the case for @dominicm as well.
Alternatively you can build lein 2.8.2 from source and use it instead.
It’s really a pity they haven’t cut a release so far.
I tried lein nrepl :headless true :middleware "['cider.nrepl/cider-middleware]"
and then connected from spacemacs
It is connecting fine except
a warning
clj-refactor refactor-nrepl are out of sync. their versions are 2.4.0 (package 20180826.2149) and n/a, respectively.
Makes sense, you need to add the refactor middleware too 🙂