Fork me on GitHub
#cider
<
2018-11-30
>
achikin12:11:43

I'm trying to start shadow-cljs repl from cider

achikin12:11:48

[nREPL] Starting server via /Users/achikin/.nvm/versions/node/v8.11.2/bin/npx shadow-cljs -d org.clojure/tools.nrepl:0.2.13 -d cider/piggieback:0.3.9 -d refactor-nrepl:2.4.0 -d cider/cider-nrepl:0.18.0 server...
Quit [2 times]
[nREPL] server started on 54547
[nREPL] Establishing direct connection to localhost:54547 ...
[nREPL] Direct connection to localhost:54547 established
[nREPL] Establishing direct connection to localhost:54547 ...
[nREPL] Direct connection to localhost:54547 established
error in process filter: user-error: Figwheel-sidecar is not available.  Please check 
error in process filter: Figwheel-sidecar is not available.  Please check 

achikin12:11:17

Should I have figwheel-sidecar in dependencies?

bozhidar13:11:19

Only if you’re using figwheel. That’s very weird.

achikin14:11:43

I'm migrating from figwheel to shadow. Maybe that's because I still have figwheel configuration bits in the project.clj.

achikin14:11:14

Anyway, as far as I understand I can remove sidecar safely and still be able to use shadow-cljs, right?

bozhidar14:11:27

Yeah, certainly.

achikin14:11:00

Show: Project-Only All 
  Hide: Clojure Java REPL Tooling Duplicates  (23 frames hidden)

1. Unhandled clojure.lang.ExceptionInfo
   missing instance
   {}

                  core.clj: 4739  clojure.core/ex-info
                  core.clj: 4739  clojure.core/ex-info
               runtime.clj:   11  shadow.cljs.devtools.server.runtime/get-instance!
               runtime.clj:    8  shadow.cljs.devtools.server.runtime/get-instance!
                   api.clj:  130  shadow.cljs.devtools.api/worker-running?
                   api.clj:  128  shadow.cljs.devtools.api/worker-running?
                   api.clj:  207  shadow.cljs.devtools.api/watch
                   api.clj:  201  shadow.cljs.devtools.api/watch
                   api.clj:  205  shadow.cljs.devtools.api/watch
                   api.clj:  201  shadow.cljs.devtools.api/watch
                      REPL:    1  user/eval55989
                      REPL:    1  user/eval55989
             Compiler.java: 7062  clojure.lang.Compiler/eval
             Compiler.java: 7051  clojure.lang.Compiler/eval
             Compiler.java: 7025  clojure.lang.Compiler/eval
                  core.clj: 3206  clojure.core/eval
                  core.clj: 3202  clojure.core/eval
                  main.clj:  243  clojure.main/repl/read-eval-print/fn
                  main.clj:  243  clojure.main/repl/read-eval-print
                  main.clj:  261  clojure.main/repl/fn
                  main.clj:  261  clojure.main/repl
                  main.clj:  177  clojure.main/repl
               RestFn.java:  137  clojure.lang.RestFn/applyTo
                  core.clj:  657  clojure.core/apply
                  core.clj:  652  clojure.core/apply
                regrow.clj:   18  refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   87  clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  657  clojure.core/apply
                  core.clj: 1965  clojure.core/with-bindings*
                  core.clj: 1965  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   85  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   55  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  222  clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
    interruptible_eval.clj:  190  clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
                  AFn.java:   22  clojure.lang.AFn/run
   ThreadPoolExecutor.java: 1142  java.util.concurrent.ThreadPoolExecutor/runWorker
   ThreadPoolExecutor.java:  617  java.util.concurrent.ThreadPoolExecutor$Worker/run
               Thread.java:  745  java.lang.Thread/run

achikin14:11:31

Should I run shadow-cljs server instace separately?

achikin15:11:40

The same happens if I start shadow-cljs server manually and do cider-connect-sibling-cljs

richiardiandrea15:11:28

I might be able to help here, could you open an issue on cider with the commands that you are running by any chance? I am using shadow day in day out so I can help with the debugging...today is tough cause I am at the Conj but I can have a look at it this evening if you open an issue

achikin16:11:01

@U0C8489U6 I have managed to run it, thanks to Thomas Heller. But I still have some questions. Seems like jump to definition does not work properly for cljs files

richiardiandrea16:11:58

Yeah well that was a bug in there that I fixed, if you give me an example or better open an issue I can have a look at it

achikin16:11:57

@U0C8489U6 which set up do you suggest? embedded shadow-cljs server or a standalone one?

richiardiandrea16:11:30

Standalone is what I use but it should not matter for the jump to definition

achikin22:11:50

@U0C8489U6 could you tell me if I'm setting the things up correctly? 1. start shadow-cljs server 2. start shadow-cljs build watch 3. cider-connect

richiardiandrea22:11:27

Last step is cider-connect-cljs for me and usually watch is also starting the server so you should be good with only that

achikin14:12:17

@U0C8489U6 it looks like when I do cider-connect-cljs cider does not parse `.shadow-cljs/.*port files. Am I right?

achikin22:12:47

@U0C8489U6 when I do cider-connect-cljs it automatically finds and parses .nrepl-port of a running lein repl.

richiardiandrea22:12:54

in my case it does the same with shadow-cljs

djwhitt15:11:54

Is there still a desire to get bencode working in ClojureScript?

bozhidar15:11:28

Not really. At this point it seems the EDN transport and the Transit transports are much better options for ClojureScript clients.

djwhitt15:11:27

Gotcha, makes sense. bencode would probably be a bit of a pain to debug in the browser.

dpsutton15:11:35

the only benefit of bencode is that there would be no client/nrepl clash of dependencies to worry about. high probability of there being transit in the project itself and maybe problems arise because of that?

dpsutton15:11:56

what if different transports are registered for edn in cider versus the actual project.

bozhidar15:11:01

EDN has exactly the same benefit.

dpsutton15:11:34

my point is that the project might have EDN and transit with special encoders that clash with what cider wants to do. just speculating no idea

djwhitt15:11:36

Yeah, exactly (re EDN). Transit is pretty slow moving too. I doubt having a newer version would cause problems on either side.

djwhitt15:11:47

Ah, hmm... hadn't thought about the encoders.

bozhidar15:11:11

I really don’t get the EDN part - nREPL’s messages are usually maps of basic types. Does someone mess with those ever?

djwhitt15:11:36

I don't want to go on too much of a tangent re encoding. Mostly I'm just wondering where the best place to help out on the ClojureScript side of things is.

bozhidar15:11:36

Btw, I’m not saying that porting nrepl/bencode to ClojureScript is a waste of time, either. I was just under the impression EDN and Transit were adequate solutions for client authors.

djwhitt15:11:09

I suspect that's mostly the case which is why I asked. Porting bencode would actually be fun since it's relatively standalone, but I figured it probably wasn't the best investment of time at this point.

erwinrooijakkers16:11:40

How can I change the cider-nrepl version that is picked up?

erwinrooijakkers16:11:17

I want to use cider/cider-nrepl 0.18.0 and not 0.19.0-SNAPSHOT

erwinrooijakkers16:11:19

My ~/.lein/profiles.clj looks like:

{:repl {:plugins [[cider/cider-nrepl "0.18.0"]
                  [refactor-nrepl "2.3.1"]]
        :dependencies [[alembic "0.3.2"]
                       [org.clojure/tools.nrepl "0.2.13"]]}}
and in the app:
{:dev
 {:dependencies [[figwheel-sidecar "0.5.16"]
                 ;; [day8.re-frame/trace "0.1.13"]
                 [org.clojure/test.check "0.9.0"]
                 [cider/cider-nrepl "0.18.0"]
                 [org.clojure/tools.nrepl "0.2.13"]
                 [cider/piggieback "0.3.10"]
                 [re-frisk "0.5.3"]]

erwinrooijakkers16:11:47

But it still picks up 0.19.0-SNAPSHOT from somewhere

erwinrooijakkers16:11:51

I am using Spacemacs

dominicm16:11:18

@erwinrooijakkers it's a cider option in emacs

dominicm16:11:33

normally derived from your cider plugin version

dpsutton17:11:27

it's kind of not an option any longer. It's added to risky var which makes it a pain to override in dir-locals because you have to accept the risky values in every file.

dpsutton17:11:34

(defvar cider-jack-in-lein-plugins nil
  "List of Leiningen plugins to be injected at jack-in.
Each element is a list of artifact name and version, followed optionally by
keyword arguments.  The only keyword argument currently accepted is
`:predicate', which should be given a function that takes the list (name,
version, and keyword arguments) and returns non-nil to indicate that the
plugin should actually be injected.  (This is useful primarily for packages
that extend CIDER, not for users.  For example, a refactoring package might
want to inject some middleware only when within a project context.)")
(put 'cider-jack-in-lein-plugins 'risky-local-variable t)
(cider-add-to-alist 'cider-jack-in-lein-plugins
                    "cider/cider-nrepl" cider-latest-middleware-version)

dpsutton17:11:53

and cider-latest-middleware-version is read at startup time and added to the list not dynamically at jack in

erwinrooijakkers17:11:27

Okay I ask because I have this problem:

erwinrooijakkers17:11:40

I get this very strange error suddenly when connecting to a MySql database:

Could not create connection to database server.
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
(...)
Caused by: java.lang.ClassCastException: java.io.BufferedWriter cannot be cast to java.io.PrintWriter
 at cider.nrepl.middleware.out$print_stream$fn__52939.invoke (out.clj:99)

erwinrooijakkers17:11:07

This only happens when I run via cider-jack-in

erwinrooijakkers17:11:19

With lein repl it works

dpsutton17:11:28

easiest way to check is to hand edit the cider-latest-middleware-version to 0.18 and try it with jacking in to see if its a regression or not

erwinrooijakkers17:11:39

Ow so I can overwrite that one

dpsutton17:11:40

there were changes to the printout out stuff recently

dpsutton17:11:56

yeah. it's all just elisp. just go to the source and change it, restart emacs and bob's your uncle

dpsutton17:11:11

if there is a regression then file a ticket

erwinrooijakkers17:11:53

Where is the cider-latest-middleware-version located?

dpsutton17:11:29

if you hit C-h V it should take you right to it

erwinrooijakkers17:11:08

I need to find cider.el

erwinrooijakkers17:11:41

It’s here: ~/.emacs.d/elpa/cider-20181128.1311

erwinrooijakkers17:11:52

Now Cider says: Source file '/Users/erooijak/.emacs.d/elpa/cider-20181128.1311/cider.el' newer than byte-compiled file

erwinrooijakkers17:11:14

And it keeps using the old one

erwinrooijakkers17:11:48

M-x byte-recompile-directory RET ~/.emacs.d/elpa/ and Bob’s my uncle

erwinrooijakkers17:11:49

Had to restart Emacs

erwinrooijakkers17:11:55

Alright the hour of truth

dpsutton17:11:41

bob is now officially you're uncle 🙂 also now you know how to edit/patch/hack on CIDER.

erwinrooijakkers17:11:13

Yes I work on a need-to-know basis

erwinrooijakkers17:11:38

When using Cider 0.18.0 the error no longer appears

dpsutton17:11:50

file an issue. that was a recent change in a very murky place. would love to have a minimal repro as well if possible ?

erwinrooijakkers17:11:09

Well that’s difficult

erwinrooijakkers17:11:12

I need some help then

erwinrooijakkers17:11:35

Stack trace:

Caused by: java.lang.ClassCastException: java.io.BufferedWriter cannot be cast to java.io.PrintWriter
 at cider.nrepl.middleware.out$print_stream$fn__53158.invoke (out.clj:99)
    cider.nrepl.middleware.out.proxy$java.io.OutputStream$ff19274a.write (:-1)
    java.io.PrintStream.write (PrintStream.java:480)
    sun.nio.cs.StreamEncoder.writeBytes (StreamEncoder.java:221)
    sun.nio.cs.StreamEncoder.implFlushBuffer (StreamEncoder.java:291)
    sun.nio.cs.StreamEncoder.flushBuffer (StreamEncoder.java:104)
    java.io.OutputStreamWriter.flushBuffer (OutputStreamWriter.java:185)
    java.io.PrintStream.write (PrintStream.java:527)
    java.io.PrintStream.print (PrintStream.java:669)
    java.io.PrintStream.println (PrintStream.java:806)
    com.mysql.jdbc.log.StandardLogger.logInternal (StandardLogger.java:318)
    com.mysql.jdbc.log.StandardLogger.logWarn (StandardLogger.java:240)
    com.mysql.jdbc.MysqlIO.doHandshake (MysqlIO.java:1177)
    com.mysql.jdbc.ConnectionImpl.coreConnect (ConnectionImpl.java:2255)
    com.mysql.jdbc.ConnectionImpl.connectOneTryOnly (ConnectionImpl.java:2286)
    com.mysql.jdbc.ConnectionImpl.createNewIO (ConnectionImpl.java:2085)
    com.mysql.jdbc.ConnectionImpl.<init> (ConnectionImpl.java:795)
    com.mysql.jdbc.JDBC4Connection.<init> (JDBC4Connection.java:44)
    sun.reflect.NativeConstructorAccessorImpl.newInstance0 (NativeConstructorAccessorImpl.java:-2)
    sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62)
    sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
    java.lang.reflect.Constructor.newInstance (Constructor.java:423)
    com.mysql.jdbc.Util.handleNewInstance (Util.java:404)
    com.mysql.jdbc.ConnectionImpl.getInstance (ConnectionImpl.java:400)
    com.mysql.jdbc.NonRegisteringDriver.connect (NonRegisteringDriver.java:327)
    java.sql.DriverManager.getConnection (DriverManager.java:664)
    java.sql.DriverManager.getConnection (DriverManager.java:208)
    clojure.java.jdbc$get_connection.invokeStatic (jdbc.clj:272)
    clojure.java.jdbc$get_connection.invoke (jdbc.clj:193)
    clojure.java.jdbc$db_query_with_resultset.invokeStatic (jdbc.clj:848)
    clojure.java.jdbc$db_query_with_resultset.invoke (jdbc.clj:818)
    clojure.java.jdbc$query.invokeStatic (jdbc.clj:874)
    clojure.java.jdbc$query.invoke (jdbc.clj:854)
    yesql.generate$query_handler.invokeStatic (generate.clj:89)
    yesql.generate$query_handler.invoke (generate.clj:82)
    yesql.generate$generate_query_fn$real_fn__32447.invoke (generate.clj:120)
    yesql.generate$generate_query_fn$query_wrapper_fn__32454.invoke (generate.clj:142)
    clojure.lang.AFn.applyToHelper (AFn.java:156)
    clojure.lang.AFn.applyTo (AFn.java:144)
    clojure.lang.AFunction$1.doInvoke (AFunction.java:29)
    clojure.lang.RestFn.invoke (RestFn.java:421)

erwinrooijakkers17:11:24

(.write ^PrintWriter @printer (String. byte-range))

erwinrooijakkers17:11:33

The printer is a BufferedWriter

erwinrooijakkers17:11:40

And PrintWriter is not a BufferedWriter

erwinrooijakkers17:11:00

They both inherit from java.io.Writer though

erwinrooijakkers17:11:12

But I don’t know why in this case we are dealing with a BufferedWriter

erwinrooijakkers18:11:23

And I really don’t understand why it only happens when calling the endpoint, but not from the REPL.

erwinrooijakkers18:11:02

I don’t see why it can be anything else than a PrintWriter

(defn tracked-sessions-map-watch [_ _ _ new-state]
  (let [out-writer (forking-printer (vals new-state) :out)
        err-writer (forking-printer (vals new-state) :err)]
    (alter-var-root #'*out* (constantly out-writer))
    (alter-var-root #'*err* (constantly err-writer))
    (System/setOut (print-stream #'*out*))
    (System/setErr (print-stream #'*err*))))

erwinrooijakkers18:11:23

Since forking-printer returns a PrintWriter

erwinrooijakkers18:11:34

I added a PR https://github.com/clojure-emacs/cider-nrepl/pull/571, although I am not yet sure why it happens. My time is up! 😄

erwinrooijakkers18:11:04

Thanks for the help!!!