Fork me on GitHub
#nrepl
<
2019-04-23
>
pez19:04:34

Can anyone see the reason why this project file:

(defproject pftv "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
            :url ""}
  :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

dominicm19:04:18

feels like something is missing.

dominicm19:04:34

oh, that doesn't fail for me

pez19:04:35

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.

dominicm19:04:23

ah, it does with your project.clj

pez19:04:33

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

pez19:04:48

What about my project.clj?

dominicm19:04:51

works for me if I remove the clojure dependency

pez19:04:18

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

dominicm19:04:33

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

dominicm19:04:38

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

pez19:04:15

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

dominicm19:04:26

No idea why it works

pez19:04:03

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

dominicm19:04:10

have you compared what cider generates for your project?

dominicm19:04:15

with an older cider version I guess?

pez19:04:14

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

dominicm19:04:45

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

pez19:04:00

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.

pez19:04:46

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.

dominicm19:04:02

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

pez19:04:16

If what is true?

dominicm19:04:51

If it fails still, sorry

dominicm19:04:09

Does criterium depends on nrepl maybe?

pez20:04:30

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

dominicm20:04:06

(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

pez20:04:06

No nrepl deps there…

dominicm20:04:46

❯ 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

dominicm20:04:44

Weird, without cider I'm getting:

❯ lein repl      
nREPL server started on port 42939 on host 127.0.0.1 - 
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=> (require 'nrepl.middleware.pr-values)

dominicm20:04:15

ah, 0.6.0 doesn't have pr-values!

dominicm20:04:44

(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

dominicm20:04:12

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

pez20:04:40

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

dominicm20:04:59

A middleware 😄

dominicm20:04:17

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

pez20:04:49

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

dominicm20:04:08

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"]

dominicm20:04:13

yeah, doesn't work 🙂

dominicm20:04:34

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

pez20:04:36

leiningen adds that?

dpsutton20:04:14

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

pez20:04:40

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.

dominicm20:04:22

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

pez20:04:48

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.

pez20:04:34

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

pez20:04:55

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?

dpsutton20:04:28

(-->
  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"
)
(<--
  id         "11"
  session    "65a5a0ee-d1f8-4fb4-ac1d-fac1df6e19c8"
  time-stamp "2019-04-23 15:28:51.876571000"
  out        "2
"
)
(<--
  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"
)
(<--
  id         "310"
  session    "65a5a0ee-d1f8-4fb4-ac1d-fac1df6e19c8"
  time-stamp "2019-04-23 15:28:51.884496000"
  status     ("done")
)

pez20:04:37

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)

dominicm20:04:39

ooh, that's a bug

dominicm20:04:53

I found that one a while ago

pez20:04:07

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

pez20:04:30

Which one did you find, @dominicm?

dpsutton20:04:39

no it didn't show up in my repl

dominicm20:04:41

that exact message, @cichli fixed it though

dpsutton20:04:50

yes 0.4.0 i believe

dpsutton20:04:10

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

pez20:04:38

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

dpsutton20:04:26

ah yes. longstanding bug

dpsutton20:04:37

responds to the subscription message i believe

pez20:04:30

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…

dpsutton20:04:33

the out-subscribe

pez20:04:20

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?

dpsutton20:04:54

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

pez20:04:36

You know where I can read about that subscription?

dpsutton20:04:36

this whole ns

❤️ 4