nrepl

https://github.com/nrepl/nrepl || https://nrepl.org
pez 2019-04-23T19:43:34.007700Z

Can anyone see the reason why this project file:

(defproject pftv "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "<http://example.com/FIXME>"
  :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
            :url "<https://www.eclipse.org/legal/epl-2.0/>"}
  :dependencies [[org.clojure/clojure "1.9.0"]
                 [criterium "0.4.4"]]
  :repl-options {:init-ns pftv.core})
With this command line:
lein update-in :dependencies conj "[nrepl \"0.5.3\"]" -- update-in :plugins conj "[cider/cider-nrepl \"0.20.0\"]" -- update-in "[:repl-options :nrepl-middleware]" conj "[\"cider.nrepl/cider-middleware\"]"  -- repl
Would fail like this:
Error loading cider.nrepl: Syntax error compiling at (cider/nrepl.clj:1:1).
...
Exception in thread "main" Syntax error compiling var at (/private/var/folders/cs/v0sbd67j3_s93nx488j890bw0000gn/T/form-init7118680432847839889.clj:1:9206).
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:7114)
	at clojure.lang.Compiler.analyze(Compiler.java:6789)
	at clojure.lang.Compiler.analyze(Compiler.java:6745)
	at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3888)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:7108)
	at clojure.lang.Compiler.analyze(Compiler.java:6789)
	at clojure.lang.Compiler.analyze(Compiler.java:6745)
	at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3888)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:7108)
	at clojure.lang.Compiler.analyze(Compiler.java:6789)
	at clojure.lang.Compiler.access$300(Compiler.java:38)
	at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6384)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:7106)
	at clojure.lang.Compiler.analyze(Compiler.java:6789)
	at clojure.lang.Compiler.analyze(Compiler.java:6745)
	at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:6120)
	at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5467)
	at clojure.lang.Compiler$FnExpr.parse(Compiler.java:4029)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:7104)
	at clojure.lang.Compiler.analyze(Compiler.java:6789)
	at clojure.lang.Compiler.eval(Compiler.java:7173)
	at clojure.lang.Compiler.eval(Compiler.java:7166)
	at clojure.lang.Compiler.eval(Compiler.java:7166)
	at clojure.lang.Compiler.eval(Compiler.java:7166)
	at clojure.lang.Compiler.load(Compiler.java:7635)
	at clojure.lang.Compiler.loadFile(Compiler.java:7573)
	at clojure.main$load_script.invokeStatic(main.clj:452)
	at clojure.main$init_opt.invokeStatic(main.clj:454)
	at clojure.main$init_opt.invoke(main.clj:454)
	at clojure.main$initialize.invokeStatic(main.clj:485)
	at clojure.main$null_opt.invokeStatic(main.clj:519)
	at clojure.main$null_opt.invoke(main.clj:516)
	at clojure.main$main.invokeStatic(main.clj:598)
	at clojure.main$main.doInvoke(main.clj:561)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.lang.Var.applyTo(Var.java:705)
	at clojure.main.main(main.java:37)
Caused by: java.lang.RuntimeException: Unable to resolve var: cider.nrepl/wrap-apropos in this context
	at clojure.lang.Util.runtimeException(Util.java:221)
	at clojure.lang.Compiler$TheVarExpr$Parser.parse(Compiler.java:720)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:7106)
	... 36 more

dominicm 2019-04-23T19:47:18.010600Z

feels like something is missing.

dominicm 2019-04-23T19:47:34.011Z

oh, that doesn't fail for me

pez 2019-04-23T19:47:35.011100Z

The background here is that I am tryin gto figure out the right jack-in command lines for Calva 2. And using nrepl 0.6.0 , cider-nrepl 0.21.1 and piggieback 0.4.0 behaves sufficiently different for the cljs repl that I would like to try use the generation before. That works nicely in my cljs test project, but then I tried with a simple clj-only project and got the above.

dominicm 2019-04-23T19:48:23.011800Z

ah, it does with your project.clj

pez 2019-04-23T19:48:33.012100Z

The above project starts smoothly if I change the command line to the latest nrepl etc.

pez 2019-04-23T19:48:48.012500Z

What about my project.clj?

dominicm 2019-04-23T19:48:51.012600Z

works for me if I remove the clojure dependency

pez 2019-04-23T19:49:18.013Z

Wow, remove it? Why did you even try that?

dominicm 2019-04-23T19:49:33.013300Z

because of the test project.clj it happened to work on when I tried it

dominicm 2019-04-23T19:49:38.013500Z

I get a lot of Error loading cider.nrepl: java.io.FileNotFoundException: Could not locate nrepl/middleware/pr_values__init.class or nrepl/middleware/pr_values.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name., compiling:(cider/nrepl.clj:1:1) on clojure 1.8.0

pez 2019-04-23T19:50:15.014100Z

I tried using clojure 1.10.0, but that didn’t help. Would never have tried to remove it.

dominicm 2019-04-23T19:50:26.014400Z

No idea why it works

pez 2019-04-23T19:51:03.015100Z

So that helps with my project, but not for Calva really…

dominicm 2019-04-23T19:53:10.015600Z

have you compared what cider generates for your project?

dominicm 2019-04-23T19:53:15.015800Z

with an older cider version I guess?

pez 2019-04-23T19:54:14.016300Z

If I remove the clojure dependency I get

Error: Could not find or load main class clojure.main
Caused by: java.lang.ClassNotFoundException: clojure.main
Subprocess failed

dominicm 2019-04-23T19:54:45.017400Z

I can go even simpler than your example though lein update-in :plugins conj "[cider/cider-nrepl \"0.20.0\"]" -- repl doesn't work, lein update-in :plugins conj "[cider/cider-nrepl \"0.21.0\"]" -- repl does

pez 2019-04-23T19:55:00.017900Z

And if I also remove the criterium dependency the repl starts, but before that a lot of complaints and of course my code needing criterium will not work.

pez 2019-04-23T19:56:46.019600Z

You mean trying with emacs/cider? No, haven’t. I will do that now. Thing is my computer does not really like emacs, which is why Calva even exists. But I will force feed it.

dominicm 2019-04-23T19:57:02.020Z

I wonder if that's true if you just put it straight into the project.clj.

pez 2019-04-23T19:57:16.020200Z

If what is true?

dominicm 2019-04-23T19:58:51.020500Z

If it fails still, sorry

dominicm 2019-04-23T19:59:09.021Z

Does criterium depends on nrepl maybe?

pez 2019-04-23T20:01:30.021700Z

I doubt it uses nrepl. But that might explain stuff. Must check.

dominicm 2019-04-23T20:05:06.022200Z

(defproject pftv "0.1.0-SNAPSHOT"
 :dependencies [[org.clojure/clojure "1.8.0"]]
 :plugins [[cider/cider-nrepl "0.20.0"]])
with lein repl is broken

pez 2019-04-23T20:05:06.022300Z

No nrepl deps there…

dominicm 2019-04-23T20:05:46.022600Z

❯ lein deps :tree    
 [cider/cider-nrepl "0.20.0"]
   [cider/orchard "0.4.0" :exclusions [[org.clojure/clojure]]]
     [org.tcrawley/dynapath "0.2.5" :exclusions [[org.clojure/clojure]]]
   [cljfmt "0.6.1" :exclusions [[org.clojure/clojure] [org.clojure/clojurescript]]]
     [com.googlecode.java-diff-utils/diffutils "1.3.0"]
     [org.clojure/tools.cli "0.3.7"]
     [rewrite-clj "0.6.0"]
     [rewrite-cljs "0.4.4"]
   [cljs-tooling "0.3.1" :exclusions [[org.clojure/clojure]]]
   [compliment "0.3.8" :exclusions [[org.clojure/clojure]]]
   [fipp "0.6.14" :exclusions [[org.clojure/clojure]]]
     [org.clojure/core.rrb-vector "0.0.13"]
   [mvxcvi/puget "1.0.2" :exclusions [[org.clojure/clojure]]]
     [mvxcvi/arrangement "1.1.1"]
   [org.clojure/java.classpath "0.3.0" :exclusions [[org.clojure/clojure]]]
   [org.clojure/tools.namespace "0.3.0-alpha4" :exclusions [[org.clojure/clojure]]]
   [org.clojure/tools.reader "1.2.2" :exclusions [[org.clojure/clojure]]]
   [org.clojure/tools.trace "0.7.10" :exclusions [[org.clojure/clojure]]]
   [thunknyc/profile "0.5.2" :exclusions [[org.clojure/clojure]]]
 [clojure-complete "0.2.5" :exclusions [[org.clojure/clojure]]]
 [nrepl "0.6.0" :exclusions [[org.clojure/clojure]]]
 [org.clojure/clojure "1.8.0"]
Looks good to me, modern nrepl version

dominicm 2019-04-23T20:06:44.022900Z

Weird, without cider I'm getting:

❯ lein repl      
nREPL server started on port 42939 on host 127.0.0.1 - <nrepl://127.0.0.1:42939>
REPL-y 0.4.3, nREPL 0.6.0
Clojure 1.8.0
OpenJDK 64-Bit Server VM 1.8.0_202-b00
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=&gt; (require 'nrepl.middleware.pr-values)

dominicm 2019-04-23T20:07:15.023100Z

ah, 0.6.0 doesn't have pr-values!

dominicm 2019-04-23T20:07:44.023400Z

(defproject pftv "0.1.0-SNAPSHOT"
 :dependencies [[org.clojure/clojure "1.8.0"]
                [nrepl "0.5.3"]]
 :plugins [[cider/cider-nrepl "0.20.0"]])
This works fine

dominicm 2019-04-23T20:08:12.023800Z

(of course, your injecting that via cli should work too, but it's not for some reasons, but now we know what is wrong)

pez 2019-04-23T20:08:40.024200Z

I’ve seen complains about pr-values. What is that?

dominicm 2019-04-23T20:08:59.024400Z

A middleware 😄

dominicm 2019-04-23T20:09:17.025Z

I have a suspicion that leiningen doesn't allow injecting the nrepl version via update-in

pez 2019-04-23T20:09:49.025500Z

Oh, wow, that would screw me up quite a lot.

dominicm 2019-04-23T20:10:08.025700Z

easily verified:

/tmp/foo                                                                1 21:09:49
❯ lein update-in :dependencies conj "[nrepl \"0.5.3\"]" -- deps :treePossibly confusing dependencies found:
[nrepl "0.6.0" :exclusions [org.clojure/clojure]]
 overrides
[nrepl "0.5.3"]

Consider using these exclusions:


 [clojure-complete "0.2.5" :exclusions [[org.clojure/clojure]]]
 [nrepl "0.6.0" :exclusions [[org.clojure/clojure]]]
 [org.clojure/clojure "1.8.0"]

dominicm 2019-04-23T20:10:13.025900Z

yeah, doesn't work 🙂

dominicm 2019-04-23T20:10:34.026300Z

nrepl is added to :dependencies before update-in has a chance to run

pez 2019-04-23T20:11:36.026600Z

leiningen adds that?

dominicm 2019-04-23T20:13:45.026800Z

yup

dpsutton 2019-04-23T20:16:14.027800Z

just realized how crazy is it that leiningen has its own project.clj file...

pez 2019-04-23T20:17:40.029100Z

OK. I would have hoped that things moved in the direction where no project includes nrepl etc , and instead the world would depend on injections.

dominicm 2019-04-23T20:18:22.029800Z

leiningen depends on it in order to provide the lein repl command

pez 2019-04-23T20:20:48.032100Z

Yeah, it makes some sense, of course, but … Anyway, this leaves me with the only option to try figure out why Calva does not work with piggieback 0.4.0 (not sure it is piggieback that is the culprit, but the hints I have gathered so far points in that direction.

pez 2019-04-23T20:21:34.032800Z

@mseddon ^ lein hardcodes nrepl 0.6.0, all bets are off ^

pez 2019-04-23T20:27:55.035400Z

So, this might be the best place to ask this. With piggieback 0.4.0 (again, I think it’s piggieback) I do not get any out or err result messages from my eval calls for the cljs repl. Am I supposed to look for them in some other way?

dpsutton 2019-04-23T20:29:28.036300Z

(--&gt;
  id                             "310"
  op                             "eval"
  session                        "65a5a0ee-d1f8-4fb4-ac1d-fac1df6e19c8"
  time-stamp                     "2019-04-23 15:28:51.837145000"
  code                           "(prn (+ 1 1))
"
  column                         1
  file                           "/Users/dan/projects/aclaimant/acl/resources/public/js/app.ou..."
  line                           56
  nrepl.middleware.print/print   "cider.nrepl.pprint/pr"
  nrepl.middleware.print/quota   1048576
  nrepl.middleware.print/stream? nil
  ns                             "pushy.core"
)
(&lt;--
  id         "11"
  session    "65a5a0ee-d1f8-4fb4-ac1d-fac1df6e19c8"
  time-stamp "2019-04-23 15:28:51.876571000"
  out        "2
"
)
(&lt;--
  id            "310"
  session       "65a5a0ee-d1f8-4fb4-ac1d-fac1df6e19c8"
  time-stamp    "2019-04-23 15:28:51.882699000"
  ns            "pushy.core"
  printed-value 1
  value         "nil"
)
(&lt;--
  id         "310"
  session    "65a5a0ee-d1f8-4fb4-ac1d-fac1df6e19c8"
  time-stamp "2019-04-23 15:28:51.884496000"
  status     ("done")
)

pez 2019-04-23T20:29:37.036500Z

Also. I get this in the terminal where I started the REPL with 0.4.0:

Exception in thread "nRepl-session-8067c4a9-e320-4f8e-b84f-890c8cbf2097" java.lang.IllegalArgumentException: No implementation of method: :send of protocol: #'nrepl.transport/Transport found for class: nil
	at clojure.core$_cache_protocol_fn.invokeStatic(core_deftype.clj:583)
	at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:575)
	at nrepl.transport$eval20664$fn__20665$G__20655__20672.invoke(transport.clj:16)
	at nrepl.middleware.print$replying_PrintWriter$fn__21121.invoke(print.clj:115)
	at nrepl.middleware.print.proxy$java.io.Writer$ff19274a.write(Unknown Source)
	at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:129)
	at java.io.BufferedWriter.flush(BufferedWriter.java:253)
	at java.io.PrintWriter.newLine(PrintWriter.java:482)
	at java.io.PrintWriter.println(PrintWriter.java:629)
	at java.io.PrintWriter.println(PrintWriter.java:757)
	at java.lang.Throwable$WrappedPrintWriter.println(Throwable.java:764)
	at java.lang.Throwable.printStackTrace(Throwable.java:655)
	at java.lang.Throwable.printStackTrace(Throwable.java:721)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
	at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
	at cljs.repl$repl_caught.invokeStatic(repl.cljc:802)
	at cljs.repl$repl_caught.invoke(repl.cljc:788)
	at cider.piggieback$repl_caught.invokeStatic(piggieback.clj:105)
	at cider.piggieback$repl_caught.invoke(piggieback.clj:98)
	at cider.piggieback$do_eval.invokeStatic(piggieback.clj:265)
	at cider.piggieback$do_eval.invoke(piggieback.clj:227)
	at cider.piggieback$evaluate.invokeStatic(piggieback.clj:273)
	at cider.piggieback$evaluate.invoke(piggieback.clj:271)
	at clojure.lang.Var.invoke(Var.java:381)
	at cider.piggieback$wrap_cljs_repl$fn__21926$fn__21929$fn__21930.invoke(piggieback.clj:305)
	at cider.piggieback$enqueue$fn__21898.invoke(piggieback.clj:195)
	at clojure.lang.AFn.run(AFn.java:22)
	at nrepl.middleware.session$session_exec$main_loop__21356$fn__21360.invoke(session.clj:171)
	at nrepl.middleware.session$session_exec$main_loop__21356.invoke(session.clj:170)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.lang.Thread.run(Thread.java:748)

dominicm 2019-04-23T20:30:39.036800Z

ooh, that's a bug

dominicm 2019-04-23T20:30:53.037100Z

I found that one a while ago

pez 2019-04-23T20:32:07.038Z

@dpsutton. you get the out message…. Is that with piggieback 0.4.0?

pez 2019-04-23T20:32:30.038400Z

Which one did you find, @dominicm?

dpsutton 2019-04-23T20:32:39.038800Z

no it didn't show up in my repl

dominicm 2019-04-23T20:32:41.038900Z

that exact message, @cichli fixed it though

dpsutton 2019-04-23T20:32:50.039200Z

yes 0.4.0 i believe

dpsutton 2019-04-23T20:33:10.039400Z

:nrepl-middleware ["cider.piggieback/wrap-cljs-repl"] is present?

pez 2019-04-23T20:33:38.040Z

You get the message, but with ID 11, I haven’t looked for it with some other ID.

dpsutton 2019-04-23T20:34:26.040200Z

ah yes. longstanding bug

dpsutton 2019-04-23T20:34:37.040400Z

responds to the subscription message i believe

pez 2019-04-23T20:36:30.042200Z

I think Calva users can live it for a while. But right now that error thrown kills my cljs repl client. I should of course try to make it handle that more gracefully…

dpsutton 2019-04-23T20:36:33.042300Z

the out-subscribe

pez 2019-04-23T20:43:20.045Z

I think I might want to get at the info in the out-subscribe, btw. Lots of users ask about where output from their apps go, and that would be a way to present it, right?

dpsutton 2019-04-23T20:45:54.045400Z

yes that's the way to get the out of the process back into the repl

pez 2019-04-23T20:53:36.046100Z

You know where I can read about that subscription?

dpsutton 2019-04-23T20:54:36.046600Z

this whole ns

❤️ 1