Fork me on GitHub
#cider
<
2018-05-21
>
theeternalpulse09:05:12

Is there a way to make cider pick up my project that isn't a boot/lein project? I am using shadow-cljs and every time I connect to nREPL

andrea.crotti11:05:31

getting wrong-type-argument stringp package-desc this morning when requiring cider this morning

andrea.crotti11:05:59

more precisely

Debugger entered--Lisp error: (wrong-type-argument stringp package-desc)
  signal(wrong-type-argument (stringp package-desc))
  epl-package-from-lisp-file("/Users/acrotti/.emacs.d/elpa/clj-refactor-20180420.223/clj-refactor.el")
  epl-package-from-file("/Users/acrotti/.emacs.d/elpa/clj-refactor-20180420.223/clj-refactor.el")
  (epl-package-version (epl-package-from-file source))
  (let* ((source (pkg-info-library-source library)) (version (epl-package-version (epl-package-from-file source)))) (pkg-info--show-version-and-return version show))
  pkg-info-library-version(clj-refactor)
  (or orig-version (pkg-info-library-version library))
  (let* ((package (or package (if (stringp library) (intern library) library))) (orig-version (condition-case nil (pkg-info-library-original-version library) (error nil))) (lib-version (or orig-version (pkg-info-library-version library))) (pkg-version (condition-case nil (pkg-info-package-version package) (error nil))) (version (if (and pkg-version (not (version-list-= lib-version pkg-version))) (format "%s (package: %s)" (pkg-info-format-version lib-version) (pkg-info-format-version pkg-version)) (pkg-info-format-version lib-version)))) (pkg-info--show-version-and-return version show))
  pkg-info-version-info(clj-refactor)
  cljr--version(t)
  cljr--inject-jack-in-dependencies()
  (lambda nil (cljr--inject-jack-in-dependencies))()
  eval-after-load-helper("/Users/acrotti/.emacs.d/elpa/cider-20180520.2317/cider.elc")
  run-hook-with-args(eval-after-load-helper "/Users/acrotti/.emacs.d/elpa/cider-20180520.2317/cider.elc")
  do-after-load-evaluation("/Users/acrotti/.emacs.d/elpa/cider-20180520.2317/cider.elc")
  require(cider)
  eval((require 'cider) nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

bozhidar11:05:39

@andrea.crotti That’s not from CIDER, it’s from clj-refactor.el.

bozhidar11:05:54

Seems something’s wrong with the package metadata, I’ve seen others report this as well.

bozhidar11:05:12

If you remove the package the error will go away.

bozhidar11:05:01

@theeternalpulse CIDER has native support for shadow projects. On jack-in you should get some prompt asking you whether to use lein or shadow.

theeternalpulse11:05:52

ah, maybe i haven't updated cider in a while

bozhidar11:05:17

@theeternalpulse This was added in 0.17.

theeternalpulse11:05:02

hmm, what about cider-connect-clojurescript, that's what I'm using

theeternalpulse11:05:19

since the nrepl server is already created by shadowcljs

theeternalpulse11:05:27

that one tells me to choose the project directory

bozhidar11:05:41

> hmm, what about cider-connect-clojurescript, that’s what I’m using

bozhidar11:05:33

If you want to associate a project with a connection there’s a command named cider-assoc-project-with-connection.

benedek11:05:38

This could be an old elc file lurking in your .emacs.d @andrea.crotti

benedek11:05:53

Try to delete and reinstall the package

andrea.crotti11:05:06

I think I deleted the whole elpa directory alraedy

andrea.crotti11:05:08

but I'll do it again

bozhidar11:05:24

No need to do this for the entire elpa. Just this one package would be enough.

bozhidar11:05:41

You can remove it from package-list-packages (for instance)

bozhidar11:05:16

@benedek Can you remind me why this was done?

benedek11:05:12

What do you mean @bozhidar?

bozhidar11:05:37

I’m planning to just move the default deps to their defvars and simplify this code. To me it makes no sense.

benedek11:05:09

Ah ok. I think we agreed with @malabarba to do this

bozhidar11:05:10

I definitely don’t think the deps are risky local variables (if you know what you’re doing).

benedek11:05:45

Perhaps there are traces of that conversation with him on the PR

andrea.crotti11:05:54

well I'm actually trying to move to emacs 26 as well in the meanwhile

andrea.crotti11:05:43

but I think now it all works fine

andrea.crotti11:05:56

but actually the bigger problem is that the cider linking to the Clojurescript repl is now not working

andrea.crotti11:05:09

I think since I upgraded this morning

benedek11:05:12

@bozhidar yeah look at pr 1552

andrea.crotti11:05:49

even though the cljs repl itself works perfectly fine and I used jack-in-clojurescript to create it

benedek11:05:34

Suppose reason is @bozhidar that we actually inserting stuff which potentially modifies your REPLs behaviour or could do other funky stuff

bozhidar12:05:33

> Suppose reason is @bozhidar that we actually inserting stuff which potentially modifies your REPLs behaviour or could do other funky stuff

bozhidar12:05:53

I’ll take a look at the PR, but if that’s the reasoning I’m going forward with my changes. 🙂

bozhidar12:05:10

> but actually the bigger problem is that the cider linking to the Clojurescript repl is now not working

bozhidar12:05:20

@andrea.crotti Can you elaborate on this?

andrea.crotti12:05:54

Since this morning if I try to evaluate some code directly in a clojurescript buffer it complains there is no repl @bozhidar

andrea.crotti12:05:04

Even if the repl is there and working

bozhidar12:05:46

Interesting. I don’t have time to test this, but I’ll try to take a look later today. I wonder if it’s not something related to the injection of piggieback I added in the morning.

bozhidar12:05:15

It actually looks as I’d expect it to.

benedek12:05:57

Cant link the comment on my phone unfortunattely :/

benedek12:05:36

comments on lines 185-188

andrea.crotti12:05:07

@bozhidar in this project we have already piggieback and in project.clj

35:                                  [com.cemerick/piggieback "0.2.2"]
     86:                   :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}}

andrea.crotti12:05:05

the figwheel auto reloading also works so it's really just evaluating in the buffer

dpsutton15:05:07

hmm. cranking up cljs project with latest CIDER changes and getting

dpsutton15:05:27

java.lang.IllegalStateException: Can't change/establish root binding of: *cljs-compiler-env* with set
	at clojure.lang.Var.set(Var.java:223)
	at cemerick.piggieback$run_cljs_repl$fn__15669.doInvoke(piggieback.clj:184)
	at clojure.lang.RestFn.invoke(RestFn.java:410)
	at cljs.repl$repl_STAR_$read_eval_print__15052.invoke(repl.cljc:881)

dpsutton15:05:37

and looks suspicious because it has cemerick piggieback in it. not sure why this used to work though

dpsutton15:05:46

Exception Failed to launch Figwheel CLJS REPL: nREPL connection found but unable to load piggieback.
This is commonly caused by
 A) not providing piggieback as a dependency and/or
 B) not adding piggieback middleware into your nrepl middleware chain.

example profile.clj code:
-----
:profiles {:dev {:dependencies [[com.cemerick/piggieback <current-version>]
                                [org.clojure/tools.nrepl  <current-version>]]
                 :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}}}
-----
Please see the documentation for piggieback here 

Note: Cider will inject this config into your project.clj.
This can cause confusion when your are not using Cider.  figwheel-sidecar.repl/eval38415/fn--38416 (repl.clj:167)
also the error looks like it still talks about the cemerick version not the cider/piggieback version

dpsutton15:05:40

updating to latest fighweel 0.5.16 and now it doesn't throw on startup but it doesn't connect to the repl

dpsutton15:05:13

Figwheel: Starting nREPL server on port: 7888
WARNING: unable to load "cemerick.piggieback/wrap-cljs-repl" middleware

manuel15:05:25

with latest CIDER and piggieback is working for me

dpsutton15:05:57

thanks. i'll keep rooting around 🙂

manuel15:05:59

I updated piggieback to 0.3.5 today

dpsutton15:05:36

ok. so fighwheel is aware of the two piggiebacks except for one spot with setting the middleware for the repl and it will inject an expectation of cemerick's version unless you specify :nrepl-middleware

dpsutton15:05:49

so taking care of that and i still cannot get a repl to connect

bozhidar16:05:54

@andrea.crotti Yeah, that’s the problem - having the old piggieback there as well.

bozhidar16:05:42

And, of course, another problem would be trying to use the new piggieback with something that doesn’t support it (e.g. an old version of figwheel).

dpsutton16:05:14

as far as i can tell current versions are [cider/piggieback "0.3.5"] and lein-figwheel "0.5.16"

bozhidar16:05:15

Well, that should certainly work.

bozhidar16:05:56

@dpsutton CIDER should be setting for you both the dep and the middleware config.

dpsutton16:05:21

i can't get it to connect even running lein figwheel. not sure where to look

dpsutton16:05:32

figwheel needs to update to not require you to set :nrepl-middleware

(defn start-nrepl-server
  [figwheel-options autobuild-options]
  (when (:nrepl-port figwheel-options)
    (let [middleware (or
                      (:nrepl-middleware figwheel-options)
                      ["cemerick.piggieback/wrap-cljs-repl"])
          resolve-mw (fn [name]
                       (let [s (symbol name)
                             ns (symbol (namespace s))]
                         (if (and
                              (utils/require? ns)
                              (resolve s))
                           (let [var (resolve s)
                                 val (deref var)]
                             (if (vector? val)
                               (map resolve val)
                               (list var)))
                           (println (format "WARNING: unable to load \"%s\" middleware" name)))))
          middleware (mapcat resolve-mw middleware)]
      (nrepl-serv/start-server
       :port (:nrepl-port figwheel-options)
       :bind (:nrepl-host figwheel-options)
       :handler (apply nrepl-serv/default-handler middleware)))))

bozhidar16:05:34

Does the lein invocation look OK to you?

dpsutton16:05:50

it looks fine. it just doesn't "see" the browser to connect

bozhidar16:05:09

> (or (:nrepl-middleware figwheel-options) [“cemerick.piggieback/wrap-cljs-repl”])

bozhidar16:05:12

What is this?

dpsutton16:05:17

That's from how figwheel starts up an nrepl server

bozhidar16:05:25

@dpsutton Sorry, I didn’t pay enough attention. Yeah, I guess @bhauman should update this.

bozhidar16:05:04

Btw, is everything working fine for you if you just use say nashorn?

bhauman16:05:42

@bozhidar @dpsutton just to be clear, you just need me to get rid of that line?

bhauman16:05:04

not update it to read "cider.piggieback/wrap-cljs-repl"

dpsutton16:05:50

so there's lots of places that you check for cider/ or cemerick/ ... I'm wondering if we could remember which is found and then require found/wrap-cljs-repl at that point

dpsutton16:05:00

but it's a lot of bookkeeping for a simple thing

dpsutton16:05:31

not a big deal. you do a good job of making lots of places aware of the two piggiebacks and that's just one place that assumes one

bhauman16:05:21

I'm surprised that folks are still using the nrepl_server in figwheel

bozhidar16:05:43

@bhauman Maybe you should add some deprecation notice for it? 🙂

bhauman16:05:43

but I'm going to fix it

bhauman16:05:03

Figwheel main is the future and it doesn't have this anymore

bozhidar16:05:37

What’s figwheel-main? I thought it was just some way to run figwheel with tools-cli.

bhauman16:05:00

figwheel-main is a complete rewrite of figwheel

dpsutton16:05:15

i guess we are using it.

:figwheel
    {:nrepl-port       7888
     :server-port      3000
     :load-all-builds  false
     :repl             true
     :ring-handler     breeze.jib.server.ring-handler/static-ring-handler
     :nrepl-middleware ["cider.piggieback/wrap-cljs-repl"]
     }

dpsutton16:05:24

and it just spins and doesn't connect to the browser

bhauman16:05:53

@dpsutton I'll fix it this morning

dpsutton16:05:40

do you know how i could start diagnosing why the repl just sits at Prompt will show when Figwheel connects to your application and doesn't see the browser? that seems to be where i am now

bhauman16:05:47

@dpsutton but that's only needed for the cider-connect workflow,

dpsutton16:05:49

and thanks so much for your help so far 👍

bhauman16:05:33

if folks aren't using that, you can comment out that line :nrepl-port and keep working for now

dpsutton16:05:33

ah. well i was getting the error message that cemerick/wrap-cljs-repl wasn't found so somehow we are using that codepath

bozhidar16:05:40

> figwheel-main is a complete rewrite of figwheel Oh! I guess I should read a bit about it. The name didn’t imply anything so significant.

bhauman16:05:16

@dpsutton did you see my previous message about commenting out :nrepl-port for now?

dpsutton16:05:30

i'm cranking it up now with that suggestion

dpsutton16:05:29

no dice 😞

bhauman16:05:55

@dpsutton where's the error? as that makes little sense to me

bhauman16:05:44

that code path only occurs if :nrep-port is available

dpsutton16:05:03

the behavior is that i jack in clojurescript, get

Successfully compiled build :raw to "target/raw/jib_out/js/jib.js" in 4.907 seconds.
Launching ClojureScript REPL for build: raw

and then my repl gets stuck at this: > Prompt will show when Figwheel connects to your application

dpsutton16:05:18

everything seems to work, i just don't have a repl. the site builds and loads

bhauman16:05:54

so that is not caused by the :nrepl-port line

dpsutton16:05:37

no it doesn't appear to be

dpsutton16:05:50

i only found that because of an assumption about cemerick's piggieback

dpsutton16:05:57

i think its unrelated for now. was just a surprising bit

dpsutton16:05:22

so the app is building just no hot-reloading now

bhauman16:05:23

yeah if its not found everything still works

bhauman16:05:50

what changed in your configuration?

dpsutton16:05:09

i upgraded CIDER.

dpsutton16:05:43

but i then responded by upgrading lein-fighweel from 5.14 to 5.16

dpsutton16:05:09

and changing the nrepl-middleware to point to cider.piggieback and switching

-                 [com.cemerick/piggieback "0.2.2"]          ; needed by figwheel nrepl
+                 [cider/piggieback "0.3.5"]          ; needed by figwheel nrepl

dpsutton16:05:54

so kind of a lot, but when i hadn't changed anything i got the warning that you can't call set! on Can't change/establish root binding of: *cljs-compiler-env* with set

bhauman16:05:39

OK are you explicitly inserting the middleware?

dpsutton16:05:57

err, if you mean the figwheel middleware yes

bhauman16:05:05

no the cider middleware

dpsutton16:05:08

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

dpsutton16:05:16

no i let the jack in process handle taht

bhauman16:05:31

oh is that happening now?

dpsutton16:05:02

do you mean cider-nrepl? that has been auto injected for a while. recently now it autoinjects cider.piggieback as well

bozhidar16:05:06

@bhauman You asked for it. 😉

dpsutton16:05:31

but i have an explicit dependency on cider/piggieback (as of this morning) since i work with some cursive users who won't get the auto

bhauman16:05:18

@dpsutton first try to insert the piggieback middleware explicitly

dpsutton16:05:46

[cider/piggieback "0.3.5"] ; needed by figwheel nrepl is in my dependencies. it used to be the explicit cemerick 0.2.2 which worked on friday

dpsutton16:05:08

with figwheel 0.5.14 and CIDER as of a week ago

dpsutton16:05:16

lots of juggling pieces 🙂

bhauman16:05:18

give this a try :nrepl-middleware ["cider.piggieback/wrap-cljs-repl"]

dpsutton16:05:39

already there

dpsutton16:05:05

i have to do that otherwise it will default to cemerick (which was the tangential bug i mentioned earlier)

bhauman16:05:35

cider-jack-in-clojurescript doesn't use these keys

bhauman16:05:51

:nrepl-port or :nrepl-middleware

bhauman16:05:58

in :figwheel

dpsutton16:05:15

ok. so make a top level :nrepl-middleware entry?

bhauman16:05:32

just like in the cider docks

bhauman16:05:59

:repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}

bhauman16:05:51

you should really remove the :nrepl-port and :nrepl-middleware keys unless someone is using the cider-connect workflow

dpsutton16:05:36

i'm not sure what a cursive workflow is. but most everyone else is on that. which runs lein figwheel raw and then conencts to that

bhauman16:05:54

oh they may use a direct connection

bhauman16:05:36

OK I'm going to upgrade cider and see what happens, should have done that first off

dpsutton16:05:53

trying now. accidentally left it as a string and it does not like that 🙂

dpsutton16:05:13

am getting this though: > [WARNING] No nREPL middleware descriptor in metadata of cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor!

bhauman16:05:27

that's fine

bhauman16:05:40

no wait that shouldn't happen

bhauman16:05:07

piggieback isn't required?

bozhidar16:05:20

Hmmm, I think I get what’s going on. The jack-in logic is quite convoluted for different tools - for lein the middleware is probably injected by the cider lein plugin or whatever.

bozhidar16:05:44

I’m busy right now, so I can’t check, but oh - I hate those differences between the tools so much…

dpsutton16:05:56

i wish lein was blessed and we all just used that

bhauman16:05:15

@bozhidar which repo's did you make changes to so I can check this out?

dpsutton16:05:17

and it had an extension for boot tasks for deployments and such

bozhidar16:05:27

We’ve got some lein plugins at play there, something different for boot and clojure-cli, nothing for gradle.

bhauman16:05:40

@dpsutton it really looks like piggieback isn't getting required

bozhidar17:05:00

Yeah, it seems the damn lein code is not using the middlewares config option at all. 😄

bozhidar17:05:20

I didn’t write this originally myself, so I keep getting surprised by how inconsistent everything there is.

bozhidar17:05:01

CIDER injects this plugin and it injects the proper lein config.

bhauman17:05:41

@bozhidar I think it would be safer for now to revert the change

bozhidar17:05:53

I guess I can check if there’s a clojurescript dependency and put something else here or make this generate the whole thing.

bhauman17:05:54

so that folks aren't broken

bozhidar17:05:04

Yeah, yeah. I’ll do this later.

dpsutton17:05:03

i can't get lein figwheel raw to work with the setup with cider.piggieback and figwheel 0.5.16. i moved my version of cider back to before any changes to the cljs jack in (to the eldoc fix) and back to cemerick/piggieback and figwheel 0.5.14 i'm back in business

dpsutton17:05:18

i can help people test after work but i'm already a morning down at the moment

bhauman17:05:56

cdier/piggieback and figwheel 0.5.16 should work

dpsutton17:05:30

@@ -50,12 +50,12 @@
                                ]]
 
                  ;; Take ring-core's newer ring-codec dep
-                 [stasis "2.3.0" :exclusions [ring/ring-codec]]
+                 [stasis "2.3.0" :exclusions [ring/ring-codec com.cemerick/piggieback]]
                  [hiccup "1.0.5"]
 
                  ;; Jib dev server dependencies
                  ;; These are not needed in production.
-                 [com.cemerick/piggieback "0.2.2"]          ; needed by figwheel nrepl
+                 [cider/piggieback "0.3.5"]          ; needed by figwheel nrepl
                  [com.cognitect/transit-clj "0.8.300"]      ; used by cljs analysis cache if present
                  [clojure-watch "0.1.13"]
                  [http-kit "2.2.0"]
@@ -64,7 +64,7 @@
 
   :plugins [[org.clojure/clojure "1.9.0"]
             [lein-cljsbuild "1.1.6" :exclusions [org.clojure/clojure]]
-            [lein-figwheel "0.5.14" :exclusions [org.clojure/core.cache]]
+            [lein-figwheel "0.5.16" :exclusions [org.clojure/core.cache]]
             [circle/s3-wagon-private "1.2.2" :exclusions [commons-codec]]
             [slothcfg "1.0.1"]
             [lein-pdo "0.1.1"]]
@@ -173,7 +173,7 @@
    {:jvm-opts
     ^:replace ["-Xmx750m" "-XX:+UseG1GC" "-XX:+UseStringDeduplication"]
 
-    :dependencies [[figwheel-sidecar "0.5.14"
+    :dependencies [[figwheel-sidecar "0.5.16"
                     :exclusions [org.clojure/clojure cljsjs/react]]
                    ;; nrepl dep is to make sidecar happy and override a default
                    ;; 0.2.12 dep from lein's base profile
@@ -187,7 +187,7 @@
      :load-all-builds  false
      :repl             false
      :ring-handler     breeze.jib.server.ring-handler/static-ring-handler
-     :nrepl-middleware ["cemerick.piggieback/wrap-cljs-repl"]}
+     :nrepl-middleware ["cider.piggieback/wrap-cljs-repl"]}

with the "before" changes I can jack in clojurescript and i can run lein figwheel raw. with the after changes neither is true as they both hang at Prompt will show when Figwheel connects to your application

bhauman18:05:27

I'm pretty sure you need this at the top level :repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}

bhauman18:05:19

@bozhidar I just did cljs-jack-in-clojurescript with the latest and the injection worked without a hitch

bhauman18:05:08

yeah it seems to work just fine

dpsutton18:05:53

well then we've got some weird stuff going on. i've done that and still not connecting to the application. i'll have to dig later tonight

bozhidar18:05:47

@bhauman Good to know. At any rate - I’ll try to spend some time in cleaning up all the injection related code.