cider

A channel dedicated to the Clojure Interactive Development Environment that Rocks (aka CIDER). :cider:
macrobartfast 2021-03-06T03:20:28.071100Z

I'm diving into the illustrious and awesome Biff framework. I'm not sure how I should be connecting to the terminal based repl that runs, in that framework, via ./task dev. I tried cider-connect-clj&cljs, chose shadow, then :app. At that point: β€’ I can evaluate a form in either repl buffer β€’ I can evaluate a form in any clj buffer (via cider-eval-defun-at-point) β€’ I can evaluate a form in any cljs buffer (via cider-eval-defun-at-point) if I switch to clojure-mode β€’ However, if I evaluate a form in a cljs buffer using cider-eval-defun-at-point nothing occurs, either in the buffer or in either repl buffer I recall having this issue before several times in non-Biff projects, so it's likely how I'm going about it all. There are a myriad of permutations of how I could be connecting from Emacs... maybe I should be trying a different approach. Any thoughts or things to try?

macrobartfast 2021-03-06T03:23:07.072300Z

If I recall, using cider-jack-in-clj&cljs often would solve this sort of problem in the past, but here I think I need to actually connect because Biff's ./task dev is doing other things. At any rate, doing so here produces

error in process sentinel: Could not start nREPL server: shadow-cljs - config: <path-to-project>/shadow-cljs.edn
shadow-cljs - connected to server
server already running

macrobartfast 2021-03-06T03:34:46.073700Z

I just noticed that, whilst in a cljs file, when in clojurescript-mode I see

cider[not connected]
but if I switch to clojure-mode it shows as being connected.

macrobartfast 2021-03-06T03:35:06.074100Z

But I do have a working cljs (as well as clj) repl buffer in all cases.

dpsutton 2021-03-06T03:55:01.075Z

this might be a longstanding issue. when in the cljs buffer, focus the cljs repl and then focus the cljs buffer again. do not go into the clj repl. it only "sees" the last repl you were in

macrobartfast 2021-03-06T04:03:54.075600Z

Ah, yes. That has worked in the past. Here, unfortunately, it doesn't. 😞

macrobartfast 2021-03-06T04:04:28.076Z

actually, hang on while I monkey around with variations on that.

macrobartfast 2021-03-06T04:18:14.076500Z

Well, that fix not working this time.

macrobartfast 2021-03-06T04:18:28.076900Z

But it's good to remember that one; it's helped in numerous occasions.

macrobartfast 2021-03-06T04:22:18.077700Z

The project team primarily use piggieback and Vim, if that's any help.

macrobartfast 2021-03-06T04:37:39.078400Z

the cljs repl says 'REPL[pending-cljs]' in the status bar, but does eval forms.

dpsutton 2021-03-06T04:44:53.079Z

Can you eval (js/alert β€œhi”)?

dpsutton 2021-03-06T04:45:09.079400Z

I’m guessing it will say unknown namespace js

dpsutton 2021-03-06T04:46:38.080300Z

If so you need to connect to the js runtime as it’s still a clj repl. Load the webpage or run the node script

macrobartfast 2021-03-06T04:49:26.080600Z

yep...

Caused by: java.lang.RuntimeException: No such namespace: js

dpsutton 2021-03-06T04:50:10.081300Z

Yeah. Is this a web app? If so load it up in the browser

dpsutton 2021-03-06T04:50:16.081600Z

You need a js engine

macrobartfast 2021-03-06T04:51:06.082400Z

It is a web app... it is loaded in the browser... I just reloaded it without success.

dpsutton 2021-03-06T04:51:48.083Z

Is figwheel on your class path ? As a dependency somewhere

macrobartfast 2021-03-06T04:51:59.083200Z

let me grep for that.

dpsutton 2021-03-06T04:53:21.084400Z

So to step back, you need an nrepl server that has cider and piggieback involved so that it can handle the js stuff for you

macrobartfast 2021-03-06T04:53:29.084600Z

okay...

macrobartfast 2021-03-06T04:54:16.085500Z

searching for piggieback... the project creator is a Vim user, so I don't know if that completely crosses over... https://github.com/jacobobryant/biff

macrobartfast 2021-03-06T04:54:43.086Z

I should just use Vim, but I'm so... addicted... to Emacs.

macrobartfast 2021-03-06T04:57:26.086700Z

He does evaluate from within a cljs file in Vim in one of his demonstrations, for what it's worth.

blak3mill3r 2021-03-06T04:57:30.086800Z

you can definitely use piggieback + emacs

macrobartfast 2021-03-06T04:57:46.087Z

whew.

macrobartfast 2021-03-06T04:58:54.087500Z

If it works for him in Vimland... does that imply it has what I need as an Emacsoid?

macrobartfast 2021-03-06T04:59:20.088300Z

It seems like he'd also need piggieback... but that's way over my head at this point.

blak3mill3r 2021-03-06T04:59:23.088400Z

I use piggieback+emacs+cider and it works wonderfully for me

blak3mill3r 2021-03-06T04:59:27.088600Z

but, you mention that

blak3mill3r 2021-03-06T04:59:35.088900Z

you have some clj buffers and some cljs buffers

macrobartfast 2021-03-06T04:59:42.089300Z

I do.

blak3mill3r 2021-03-06T04:59:48.089600Z

and, while I understand that this does work for some people, I haven't used it that way

blak3mill3r 2021-03-06T05:00:02.090100Z

I'm generally writing one or the other, in a particular instance of emacs

macrobartfast 2021-03-06T05:00:10.090500Z

things eval in the clj and cljs repl buffers, and in clj files, and clj will eval in cljs buffers when in clojure-mode...

blak3mill3r 2021-03-06T05:00:13.090700Z

I think it should work fine with 2 nrepl connections

blak3mill3r 2021-03-06T05:00:36.091300Z

yes but when you are setting clojure-mode in your cljs buffer, are you sure it is evaluating clojurescript and not clojure?

blak3mill3r 2021-03-06T05:00:48.091800Z

Caused by: java.lang.RuntimeException: No such namespace: js

blak3mill3r 2021-03-06T05:00:59.092300Z

looks suspiciously like you are sending clojurescript code to your JVM clojure process

macrobartfast 2021-03-06T05:01:06.092500Z

I am guessing it is eval'ing clojure.

blak3mill3r 2021-03-06T05:01:10.092700Z

yeah so

blak3mill3r 2021-03-06T05:01:18.093100Z

what you want to do is use piggieback

blak3mill3r 2021-03-06T05:01:26.093500Z

to sort of switch modes...

blak3mill3r 2021-03-06T05:01:35.093900Z

you can also have 2 active CIDER connections

macrobartfast 2021-03-06T05:01:37.094200Z

I wonder where I'd add that in to this framework (https://github.com/jacobobryant/biff) then...

blak3mill3r 2021-03-06T05:01:37.094300Z

2 repl buffers

blak3mill3r 2021-03-06T05:02:00.095100Z

I haven't seen this biff framework, I will take a look

macrobartfast 2021-03-06T05:02:13.095500Z

because the last I understood anything was in the glorious simple days of project.clj and so on.

macrobartfast 2021-03-06T05:02:25.095900Z

Then the clone wars happened, things got complicated, and all that.

macrobartfast 2021-03-06T05:02:53.096400Z

Biff is actually phenomenal. But it's what one would call a 'learning opportunity' for a simpleton like me.

macrobartfast 2021-03-06T05:03:33.096700Z

Here is his overview page: https://findka.com/biff/#introduction

blak3mill3r 2021-03-06T05:04:47.097800Z

you are using figwheel; figwheel's cljs-repl supports (expects, I think) piggieback to be on your classpath

blak3mill3r 2021-03-06T05:04:54.098Z

are you using leiningen?

blak3mill3r 2021-03-06T05:05:28.099100Z

is your name a play on Slartibartfast?

macrobartfast 2021-03-06T05:05:32.099200Z

I normally do, but here I run the framework's

./task dev
and I should try to find out what that is doing more.

macrobartfast 2021-03-06T05:05:53.099600Z

It is composed of simple Clojure idioms, however.

blak3mill3r 2021-03-06T05:07:46.100400Z

https://github.com/jacobobryant/biff/blob/master/task

blak3mill3r 2021-03-06T05:07:51.100700Z

it's an extremely short bash script

macrobartfast 2021-03-06T05:07:59.101Z

haha... and yes, my name is indeed a play on Slartibartfast. πŸ˜€

blak3mill3r 2021-03-06T05:08:22.101400Z

I'd rather be happy than right, any day

macrobartfast 2021-03-06T05:08:46.101600Z

"Perhaps I'm old and tired, but I think that the chances of finding out what's actually going on are so absurdly remote that the only thing to do is to say, "Hang the sense of it," and keep yourself busy. I'd much rather be happy than right any day."

macrobartfast 2021-03-06T05:08:57.102Z

haha... our messages crossed, lol.

blak3mill3r 2021-03-06T05:09:22.102200Z

cider/piggieback {:mvn/version "0.4.1"}

blak3mill3r 2021-03-06T05:09:37.102600Z

^ add this to your ~/.clojure/deps.edn (or to your project's deps.edn)

macrobartfast 2021-03-06T05:10:00.102800Z

ok, on it.

blak3mill3r 2021-03-06T05:10:25.103Z

sorry that version is not up to date

blak3mill3r 2021-03-06T05:10:34.103300Z

there are some other dependencies too which you may or may not already have

blak3mill3r 2021-03-06T05:10:45.103600Z

:aliases {:nrepl
          {:extra-deps
            {nrepl/nrepl {:mvn/version "0.8.2"}
             cider/piggieback {:mvn/version "0.5.2"}}}}
^ these are recent, from the figwheel README

macrobartfast 2021-03-06T05:11:18.104300Z

it goes under :aliases?

blak3mill3r 2021-03-06T05:11:18.104400Z

I believe you need to configure figwheel to use cider/piggieback too

blak3mill3r 2021-03-06T05:11:41.105400Z

yes :aliases is one way to do it

macrobartfast 2021-03-06T05:11:43.105500Z

Bruce is straight out of Hitchhikers.

blak3mill3r 2021-03-06T05:11:56.105900Z

it depends if you think that figwheel is a personal development tool

blak3mill3r 2021-03-06T05:12:01.106100Z

or part of your projects dev dependencies

blak3mill3r 2021-03-06T05:12:07.106300Z

you can put it in the project's deps.edn

blak3mill3r 2021-03-06T05:12:20.106600Z

if you want other users of your app to have it for sure

blak3mill3r 2021-03-06T05:12:44.107200Z

your figwheel config probably wants to configure the nREPL middleware

macrobartfast 2021-03-06T05:12:45.107500Z

I'm putting it in globally.

blak3mill3r 2021-03-06T05:12:52.107800Z

see where it says

Load CIDER, refactor-nrepl and piggieback middleware

macrobartfast 2021-03-06T05:13:06.108300Z

piggieback, that is.

blak3mill3r 2021-03-06T05:13:09.108400Z

without that it will sort of work in a crippled way (lots of CIDER features missing)

macrobartfast 2021-03-06T05:14:34.108700Z

ok... trying to get that all in.

blak3mill3r 2021-03-06T05:15:20.109200Z

I am trying to catch up on what biff is doing when you run ./task dev

blak3mill3r 2021-03-06T05:15:30.109500Z

but you do have figwheel running, right?

blak3mill3r 2021-03-06T05:15:55.110Z

I have a function in my clojure dev namespace that first starts figwheel and then calls figwheel-sidecar.repl-api/cljs-repl

blak3mill3r 2021-03-06T05:16:05.110400Z

which converts the clojure nREPL connection to a clojurescript one, using piggieback

macrobartfast 2021-03-06T05:16:06.110500Z

I don't know if I do...

macrobartfast 2021-03-06T05:16:46.111200Z

that is, if I have figwheel running.

blak3mill3r 2021-03-06T05:16:53.111600Z

ok

macrobartfast 2021-03-06T05:17:07.112100Z

I once understood things... barely... then boot came along, then the successors...

blak3mill3r 2021-03-06T05:17:11.112300Z

is the code something you can share?

blak3mill3r 2021-03-06T05:17:31.113Z

or, if I generate a new empty biff project and get emacs+cider+piggieback working would that help?

macrobartfast 2021-03-06T05:17:40.113300Z

omg, tremendously.

macrobartfast 2021-03-06T05:18:09.113900Z

I would also then be the rather dubious Biff Emacs integration expert, as well.

macrobartfast 2021-03-06T05:18:44.114400Z

Presumably I could write it up for the Biff docs.

macrobartfast 2021-03-06T05:20:29.115600Z

And eventually add it to the project, for the Emacsians. But I'd probably have folks here audit it first, lol.

blak3mill3r 2021-03-06T05:21:34.116600Z

I am fiddling about

macrobartfast 2021-03-06T05:21:42.116800Z

OK, I'll shut up.

blak3mill3r 2021-03-06T05:21:49.117100Z

haha, not what I meant

macrobartfast 2021-03-06T05:21:53.117400Z

I know.

blak3mill3r 2021-03-06T05:24:34.118400Z

did you say that you were using figwheel? because it seems like my newly generated biff project uses shadow-cljs

blak3mill3r 2021-03-06T05:24:51.118800Z

I see nothing indicating that it uses figwheel

macrobartfast 2021-03-06T05:26:55.119Z

aha.

macrobartfast 2021-03-06T05:27:27.119700Z

I don't even know what I am using... I connect via cider-connect-clj&cljs from within Emacs.

macrobartfast 2021-03-06T05:27:45.120100Z

So I don't know if that implies figwheel or not.

dpsutton 2021-03-06T05:27:48.120200Z

how are you starting the repl?

blak3mill3r 2021-03-06T05:28:14.121100Z

with this arcane bash stuff in biff ... I am looking into what it does

macrobartfast 2021-03-06T05:28:15.121200Z

Well, in this case, the repl is started by the framework...

blak3mill3r 2021-03-06T05:28:23.121900Z

dev () {
  if ! [ -e node_modules ]; then
    init
  fi
  npx onchange -i tailwind.css -- ./task build-css-dev &
  trap 'kill $(jobs -p) 2> /dev/null' EXIT
  mopt="-A"
  if clj -Sdescribe | grep -q repl-aliases; then
    mopt="-M"
  fi
  BIFF_ENV=dev clj $mopt:cljs "$@" -m $MAIN_NS
}

blak3mill3r 2021-03-06T05:28:26.122100Z

that's what it does ^

blak3mill3r 2021-03-06T05:28:32.122600Z

when you run ./task dev

dpsutton 2021-03-06T05:28:35.122900Z

yeah. its crazy. yes. so are you calling ./task dev?

macrobartfast 2021-03-06T05:28:35.123Z

thank you, was just about to paste it.

macrobartfast 2021-03-06T05:28:40.123300Z

I am.

dpsutton 2021-03-06T05:28:55.123900Z

ok. i'm not sure how you're even connecting to that. i don't see any nrepl getting started or involved

blak3mill3r 2021-03-06T05:28:57.124100Z

and, when I did this, I got some complaints about it not finding cider/nrepl and refactor-nrepl/middleware

macrobartfast 2021-03-06T05:29:06.124500Z

hang on, let me look.

dpsutton 2021-03-06T05:29:32.125200Z

i'm confused why it even has an nrepl server. that's just calling clj -M:cljs -m example.core or whatever

blak3mill3r 2021-03-06T05:29:49.125400Z

right

blak3mill3r 2021-03-06T05:29:58.125700Z

perhaps they bake it in

macrobartfast 2021-03-06T05:30:38.126100Z

I'm digging around, but pretty slow on the uptake on this.

macrobartfast 2021-03-06T05:31:35.126500Z

when you run ./task dev, this is in the output in the terminal:

Downloading: cider/piggieback/0.5.2/piggieback-0.5.2.pom from clojars

blak3mill3r 2021-03-06T05:32:13.127400Z

is that because you added piggieback as a dependency in your ~/.clojure/deps.edn perhaps?

dpsutton 2021-03-06T05:32:29.128200Z

ok. so shadow is in charge of the nrepl stuff. but there's no middleware so CIDER can't work with it. wont need piggieback in a shadow-cljs project

dpsutton 2021-03-06T05:32:43.128700Z

so that's not an issue. its just getting shadow setup with the correct middleware

macrobartfast 2021-03-06T05:32:53.129200Z

I don't think so... you do finally get

shadow-cljs - nREPL server started on port 7888

dpsutton 2021-03-06T05:32:59.129600Z

and the main ns calls biff/start-system with its own map

blak3mill3r 2021-03-06T05:33:22.130Z

cider docs have instructions on cljs jack-in with shadow-cljs here https://docs.cider.mx/cider/cljs/shadow-cljs.html#using-cider-jack-in-cljs

blak3mill3r 2021-03-06T05:33:50.130800Z

@macrobartfast I thought I understood you to say that you were using figwheel, but I think that is not the case... maybe I misunderstood

macrobartfast 2021-03-06T05:33:59.130900Z

I tried cider-jack-in-cljs but had issues...

dpsutton 2021-03-06T05:34:27.132Z

this stuff is absolutely crazy and i can't see you getting it running with CIDER unless you're an expert

dpsutton 2021-03-06T05:34:50.132900Z

(nrepl/start-server :port 7888) is burried in biff.components and is called by biff/start-system

macrobartfast 2021-03-06T05:34:57.133300Z

well, that's helpful to know...

blak3mill3r 2021-03-06T05:35:00.133500Z

haha this framework looks ... deep ... I am trying to get it to work with jack-in-cljs

blak3mill3r 2021-03-06T05:35:19.134200Z

it looks cool but yeah, adding cider+cljs is not going to be super obvious

macrobartfast 2021-03-06T05:35:56.135200Z

I had thought it was just a matter of choosing the right cider command in Emacs or whatnot, lol...

dpsutton 2021-03-06T05:36:23.136Z

some things you could do is pass :biff.init/start-nrepl false and be in charge of your own nrepl server. but the challenge is that all of this stuff is kinda twice removed from your own project

dpsutton 2021-03-06T05:37:01.136700Z

so you need to tell it to not do anything and then do everything correctly yourself. but the css is watched in some random shell scripts, the nrepl and shadow started elsewhere, etc

dpsutton 2021-03-06T05:37:46.137800Z

i don't care for this kind of thing. i much prefer you being in control of starting nrepl, and shadow.

(defn init [sys]
  (let [env (keyword (or (System/getenv "BIFF_ENV") :prod))
        unmerged-config (bu/catchall (edn/read-string (slurp "config/main.edn")))
        config (some-> unmerged-config (merge-config env))
        {:biff/keys [first-start dev]
         :biff.init/keys [start-nrepl start-shadow]
         :as sys} (merge sys config {:biff/unmerged-config unmerged-config})]
    (let [start-nrepl (if (some? start-nrepl) start-nrepl (not dev))
          start-shadow (if (some? start-shadow) start-shadow dev)]
      (when (and first-start start-nrepl)
        (nrepl/start-server :port 7888))
      (when (and first-start start-shadow)
        ; Without this, I sometimes get the following when loading localhost:9630:
        ; java.lang.Exception: Unable to resolve spec: :edn-query-language.core/property
        (require 'edn-query-language.core)
        ((requiring-resolve 'shadow.cljs.devtools.server/start!)))
      sys)))

macrobartfast 2021-03-06T05:37:48.138100Z

yeah... that's what made me think I wouldn't be able to just jack in, as it were...

dpsutton 2021-03-06T05:38:06.138500Z

here's all the code in biff that does this stuff. so you need to smuggle all your middleware down through to here, etc

macrobartfast 2021-03-06T05:38:32.139100Z

gotcha, ok...

blak3mill3r 2021-03-06T05:38:37.139500Z

I have discovered something... I know why it complained about middleware not found when I started ./task dev

dpsutton 2021-03-06T05:38:55.140200Z

#:biff{:first-start first-start
       :routes routes
       :static-pages pages
       :event-handler #(api % (:?data %))
       :rules #'rules
       :triggers #'triggers
       :jobs jobs
       :send-email #'send-email
       :after-refresh `after-refresh}
and here's the knobs you have to thread all that stuff down

blak3mill3r 2021-03-06T05:39:03.140500Z

it's because, shadow-cljs.edn has :deps {:aliases [:cljs]} in it and that is an alias I have defined globally

dpsutton 2021-03-06T05:39:34.141100Z

nah its because of this line from above: (nrepl/start-server :port 7888) no way to get middleware into there

blak3mill3r 2021-03-06T05:39:55.141400Z

isn't there ... an edn file

blak3mill3r 2021-03-06T05:40:07.141700Z

yeah there is

blak3mill3r 2021-03-06T05:40:12.142300Z

cat ~/.nrepl/nrepl.edn 
;; can be overridden locally with .nrepl.edn ... which replaces (not merges) those here
{:bind "localhost"
 :middleware [cider.nrepl/cider-middleware
              #_cider.piggieback/wrap-cljs-repl
              refactor-nrepl.middleware/wrap-refactor]}

dpsutton 2021-03-06T05:40:53.142900Z

oh yeah. i hate the idea of globally defined files for this stuff. that's system wide and expects random projects to have those deps

blak3mill3r 2021-03-06T05:41:12.143500Z

I mean, I agree with @dpsutton in spirit... I don't like too much magic around starting the system

dpsutton 2021-03-06T05:41:13.143700Z

so many issues from old profiles.clj people have laying around

blak3mill3r 2021-03-06T05:41:22.144Z

but I still think I can make this biff + cider thing work with what's there

macrobartfast 2021-03-06T05:41:34.144300Z

I understand where you're coming from, @dpsutton.

dpsutton 2021-03-06T05:42:52.146700Z

but anyways, this is all designed if just connect to an nrepl port with no other requirements. cider will be very neutered in this thing.

macrobartfast 2021-03-06T05:43:02.146900Z

This project is an effort to get a more turn-key thing going for people, but it fairly bound to a specific editor, at the moment, it seems, at least for inline eval'ing.

macrobartfast 2021-03-06T05:44:16.148200Z

This has exposed my lack of comprehension of cider and figwheel in general... which is a good thing.

macrobartfast 2021-03-06T05:44:42.148800Z

It's probably time for me to finally put more effort into understanding the repl magic I like so much.

macrobartfast 2021-03-06T05:46:43.150200Z

I kind of understood things when figwheel first came out (yay, flappy bird)... but things got increasingly complex for me to grok.

blak3mill3r 2021-03-06T06:07:14.152700Z

So... while I am not sure exactly which features of cider+figwheel you loved, I want to point out that shadow-cljs is a very different way of working with clojurescript; I have not yet tried it, but I suspect that dpsutton is correct that a ton of useful CIDER stuff will be missing

blak3mill3r 2021-03-06T06:07:36.153300Z

it sounds like you can get some of the same features (live cljs recompilation, cljs repl)

macrobartfast 2021-03-06T06:08:01.153800Z

gotcha... mainly, I like being able to hit a db from within the code...

macrobartfast 2021-03-06T06:08:13.154300Z

as well as atoms...

blak3mill3r 2021-03-06T06:08:22.154900Z

hit a db ... from jvm clojure right?

macrobartfast 2021-03-06T06:08:29.155100Z

so I can refine my functions.

macrobartfast 2021-03-06T06:08:47.155600Z

Well, db from Clojure, atoms and remote calls from ClojureScript.

macrobartfast 2021-03-06T06:09:32.156200Z

That's my general use, anyway.

blak3mill3r 2021-03-06T06:09:38.156600Z

ok, good

blak3mill3r 2021-03-06T06:09:44.156800Z

then you wont miss the rest of the CIDER features

blak3mill3r 2021-03-06T06:09:52.157200Z

I am still fiddling about

macrobartfast 2021-03-06T06:09:56.157500Z

I'd be cool probably without them.

blak3mill3r 2021-03-06T06:10:07.158Z

thus far I have not gotten biff to start and have cider middleware

macrobartfast 2021-03-06T06:10:23.158400Z

ok... massive gratitude, btw...

blak3mill3r 2021-03-06T06:11:05.159300Z

happy to try

blak3mill3r 2021-03-06T06:11:23.159900Z

biff does look interesting... it is far from the way I am used to working with clojurescript though

macrobartfast 2021-03-06T06:11:56.160500Z

Biff is a cool project in general, and so if I can get it to work I learn all about crux and so on, the things baked into the framework.

macrobartfast 2021-03-06T06:14:46.162800Z

It also allows you to deploy a site to the very affordable Digital Ocean very quickly with a lot of features I want in a basic project... and I like to experiment so it's appealing.

blak3mill3r 2021-03-06T06:19:29.163Z

ooh it uses crux? very cool

blak3mill3r 2021-03-06T06:20:09.164100Z

well I got a cider+piggieback cljs repl working in emacs with my biff project ... but I'm not there yet

macrobartfast 2021-03-06T06:22:24.165500Z

I'm as excited as a pomeranian on the back dash of a car who's just spotted its owner come out of a donut shop.

blak3mill3r 2021-03-06T06:23:26.166100Z

unfortunately I think what I've done is not compatible with the way biff starts the repl though

blak3mill3r 2021-03-06T06:24:54.167600Z

oddly it sounds like piggieback + shadow-cljs is not really a thing, even though the vim-fireplace code supposedly supports converting to a cljs repl with shadow-cljs, and calls this feature :Piggieback ... I think the relationship is in name only

blak3mill3r 2021-03-06T06:25:32.168100Z

@macrobartfast do you know if anybody is using biff without shadow-cljs?

macrobartfast 2021-03-06T06:25:41.168400Z

I don't think anyone is.

macrobartfast 2021-03-06T06:25:50.168800Z

I don't know, really...

macrobartfast 2021-03-06T06:26:01.169300Z

but it's a fairly new project.

blak3mill3r 2021-03-06T06:26:33.169900Z

it is possible that the Right Way to accomplish this (cider+biff) is to provide an alternative that starts nREPL with cider middleware and then uses piggieback to turn it into a cljs repl

macrobartfast 2021-03-06T06:26:58.170800Z

the framework creator would probably be super down for that...

blak3mill3r 2021-03-06T06:27:01.171Z

that is going to have the advantage of supporting all the amazing CIDER features;

macrobartfast 2021-03-06T06:27:13.171500Z

they indicated curiosity about Emacs in general.

blak3mill3r 2021-03-06T06:27:38.172200Z

the thing is, the selling points of shadow-cljs don't apply to everyone... this is the kind of thing that makes designing opinionated frameworks extremely challenging

blak3mill3r 2021-03-06T06:27:46.172400Z

IIUC

blak3mill3r 2021-03-06T06:28:59.174300Z

I mean I have always loved using figwheel and piggieback, and didn't mind that it was running JVM clojure for the cljs compilation. I am not an expert on shadow-cljs at all, but IIUC it is using the self-hosted CLJS compiler

macrobartfast 2021-03-06T06:29:00.174400Z

well, the framework touches on one of the Clojure conundrums in general... how to get a greenfield project up and deployed with usual features in a short amount of time...

macrobartfast 2021-03-06T06:29:50.175900Z

and I guess I would go to another language for that sort of situation... but, of course, I'm not going to for all the reasons none of us would.

blak3mill3r 2021-03-06T06:30:23.176500Z

nah I must be wrong about that... clearly shadow-cljs is starting a clojure process here

blak3mill3r 2021-03-06T06:31:28.177600Z

I don't see anything fundamentally wrong with the idea of having another way to start biff that uses piggieback. I was able to make it work (but not loading the actual biff app's cljs sources)

blak3mill3r 2021-03-06T06:31:52.178200Z

I mean, I created a biff project, added the necessary middleware, and then I was able to get piggieback to work compiling something in the context of that project

blak3mill3r 2021-03-06T06:34:11.179200Z

that is really far from the way biff has it working though, with shadow-cljs

macrobartfast 2021-03-06T06:34:17.179300Z

pomeranian actually shatters rear windshield

❀️ 1
blak3mill3r 2021-03-06T06:35:36.180700Z

https://github.com/tpope/vim-fireplace/issues/322 refers to some CIDER doc that says that shadow-cljs provides its own middleware so maybe I am going about this totally the wrong way trying to use piggieback

macrobartfast 2021-03-06T06:37:57.181200Z

omg this is all deep... reading that now.

blak3mill3r 2021-03-06T06:41:17.181600Z

I do actually see some evidence that biff without shadow-cljs might be a thing already

macrobartfast 2021-03-06T06:44:36.182400Z

I just asked the Biff main author about this.

blak3mill3r 2021-03-06T06:48:51.182900Z

it seems like maybe the biff SPA only knows how to compile the cljs using shadow-cljs though

macrobartfast 2021-03-06T06:54:11.183600Z

biff.core/default-mpa-components…

macrobartfast 2021-03-06T06:55:01.183900Z

:biff/start-shadow...

blak3mill3r 2021-03-06T06:56:51.184100Z

yeah I found that

blak3mill3r 2021-03-06T06:57:04.184500Z

but without shadow, there's no clojurescript compiler included, unless I am missing something

blak3mill3r 2021-03-06T06:57:23.184900Z

however I did just get a cljs repl buffer in emacs that was connected to the browser which had my biff app loaded

blak3mill3r 2021-03-06T06:57:50.185800Z

but wasn't able to get my emacs clojurescript-mode buffers to eval over this connection

macrobartfast 2021-03-06T06:58:11.186Z

ah ok

macrobartfast 2021-03-06T06:58:56.186800Z

I had a cljs repl... but I don't know if it was browser based... js/alert never worked IIRC

blak3mill3r 2021-03-06T06:59:47.187600Z

I have used cider-connect-cljs and connected successfully to the nREPL server started by ./task dev which is launching shadow-cljs

blak3mill3r 2021-03-06T07:00:02.188100Z

so I have a cider-repl buffer in emacs, in which (js/alert 1) works

blak3mill3r 2021-03-06T07:00:06.188300Z

with the biff app in the browser

blak3mill3r 2021-03-06T07:00:11.188500Z

this is pretty close to what you want

blak3mill3r 2021-03-06T07:00:18.188700Z

but not quite

blak3mill3r 2021-03-06T07:00:42.189400Z

I don't understand yet why the clojurescript-mode buffer is not sesman-linked with the cljs repl connection

macrobartfast 2021-03-06T07:02:12.190Z

googling sesman

blak3mill3r 2021-03-06T07:02:25.190200Z

an emacs dependency of cider

blak3mill3r 2021-03-06T07:02:40.190700Z

which allows it to have multiple nrepl connections simultaneously, and each buffer associated with one of them

macrobartfast 2021-03-06T07:03:06.191400Z

gotcha

blak3mill3r 2021-03-06T07:03:07.191500Z

this is where the forms go when you cider-eval-last-defun for example (for each buffer, sesman associates it with an nrepl connection)

blak3mill3r 2021-03-06T07:03:26.192100Z

it seems like it should've been associated after I got cider-connect-cljs to work

blak3mill3r 2021-03-06T07:03:33.192500Z

with the shadow-cljs option (`:app`)

blak3mill3r 2021-03-06T07:03:48.193200Z

but it aint yet 😒

macrobartfast 2021-03-06T07:04:07.193400Z

right?

macrobartfast 2021-03-06T07:04:18.193600Z

all I wanted was a Pepsi.

blak3mill3r 2021-03-06T07:06:03.193900Z

aha, the slack archives has a clue! https://clojurians-log.clojureverse.org/cider/2020-05-18

macrobartfast 2021-03-06T07:07:50.194400Z

perusing that.

macrobartfast 2021-03-06T07:08:25.194700Z

but also the basics https://shadow-cljs.github.io/docs/UsersGuide.html#missing-js-runtime

macrobartfast 2021-03-06T07:12:27.195Z

are you trying those newer versions?

blak3mill3r 2021-03-06T07:18:38.195500Z

bummer ... the symptom I am seeing now is identical to that person in the slack archive

blak3mill3r 2021-03-06T07:20:34.197500Z

I wanted to update the versions but ran into some troubles; there is presumably a transitive dependency on clojure/clojurescript from either shadow-cljs or from biff itself

macrobartfast 2021-03-06T07:20:47.198Z

I am cleaning up my shadow-cljs situation... turns out I didn't have a top level shadow-cljs.edn, for starters...

blak3mill3r 2021-03-06T07:20:54.198400Z

anyway that version mentioned in the slack archive as "fixing" (somewhat mysteriously) the issue is old-ish today

macrobartfast 2021-03-06T07:21:11.199Z

gotcha

blak3mill3r 2021-03-06T07:21:14.199100Z

I don't have a top-level shadow-cljs.edn either

macrobartfast 2021-03-06T07:22:35.199800Z

I had one in my Documents folder, lol, from another project.

macrobartfast 2021-03-06T07:22:39.200Z

It found it.

macrobartfast 2021-03-06T07:23:45.200500Z

I am learning a ton right now.

macrobartfast 2021-03-06T07:26:14.201Z

ok, have a js/alert working from the cljs repl now myself, which is progress.

blak3mill3r 2021-03-06T07:28:02.203Z

it seems like it is very very close to working, my own cider-repl buffer that came from cider-connect-cljs to the shadow-cljs nrepl is stuck in a state pending-cljs (even though it is clearly sending code to the browser itself, this prevents cider-eval-* from working in clojurescript-mode buffers)

macrobartfast 2021-03-06T07:28:04.203200Z

that, after putting in a global shadow-cljs.edn in ~/.shadow-cljs/config.edn with the most recent cider-nrepl version.

blak3mill3r 2021-03-06T07:28:26.203700Z

makes sense, that's something like what I did

macrobartfast 2021-03-06T07:28:36.203900Z

I have had that pending-cljs message too.

blak3mill3r 2021-03-06T07:28:52.204100Z

https://github.com/clojure-emacs/cider/issues/2456

blak3mill3r 2021-03-06T07:29:53.204500Z

track-state middleware...

macrobartfast 2021-03-06T07:31:32.205Z

"Also - are all of you using the latest piggieback?"

blak3mill3r 2021-03-06T07:32:35.205200Z

your pomeranian is gonna love this

blak3mill3r 2021-03-06T07:32:41.205400Z

πŸŽ‰

blak3mill3r 2021-03-06T07:32:51.205700Z

try the following

blak3mill3r 2021-03-06T07:33:09.206100Z

eval this elisp (setq cider-repl-auto-detect-type nil)

blak3mill3r 2021-03-06T07:33:27.206600Z

then with your pending-cljs repl active

blak3mill3r 2021-03-06T07:33:43.207200Z

execute cider-set-repl-type and choose cljs

blak3mill3r 2021-03-06T07:34:51.208100Z

it is working for me

blak3mill3r 2021-03-06T07:35:14.208600Z

cider docs say this can happen "in rare cases such as a bug in shadow-cljs" (paraphrased)

macrobartfast 2021-03-06T07:35:40.209400Z

doing it now

blak3mill3r 2021-03-06T07:36:05.210Z

the reality is that whatever the track-state middleware is supposed to do to allow cider to detect that the repl has become a cljs repl is broken (perhaps the way biff is running shadow-cljs simply does not load the track-state middleware, or it could be that it loads it in the wrong order, etc)

blak3mill3r 2021-03-06T07:36:31.210600Z

but now I have cider+biff with cljs cider-eval-* and hot compilation of clojurescript (a la figwheel)

macrobartfast 2021-03-06T07:38:12.211300Z

om#g.

blak3mill3r 2021-03-06T07:38:13.211500Z

:cider: ?

macrobartfast 2021-03-06T07:38:14.211600Z

it works.

blak3mill3r 2021-03-06T07:38:16.211800Z

hooray

macrobartfast 2021-03-06T07:38:36.212200Z

died. applying defibrillation paddles. back.

blak3mill3r 2021-03-06T07:38:48.212400Z

drink some cider

macrobartfast 2021-03-06T07:38:56.212600Z

hahaha

macrobartfast 2021-03-06T07:39:08.212900Z

I've dodged the Vim bullet, again.

blak3mill3r 2021-03-06T07:39:11.213Z

and Don't Panic

macrobartfast 2021-03-06T07:39:28.213800Z

well, I do use evil mode in emacs, but don't tell anyone.

blak3mill3r 2021-03-06T07:40:23.214800Z

a ton of people do... I used vim for 12 years and before I switched to emacs

blak3mill3r 2021-03-06T07:40:47.215400Z

you should make sure to write down how we got it working

macrobartfast 2021-03-06T07:41:16.216500Z

This was epic. I am copying this entire session and having it engraved on a palladium plate.

blak3mill3r 2021-03-06T07:41:21.216800Z

I myself am a little tired and forgetful, though I think I know which bits were essential to my poking about

macrobartfast 2021-03-06T07:41:40.217200Z

I'm keeping it all. Because next week I'll be right at the start of it again.

macrobartfast 2021-03-06T07:42:10.217700Z

two palladium plates... one for launching beyond our solar system.

macrobartfast 2021-03-06T07:42:40.218400Z

I'm sure they'll be able to puzzle out our entire planet by studying that.

macrobartfast 2021-03-06T07:43:09.218800Z

hahaha

macrobartfast 2021-03-06T07:43:21.219100Z

good lord, so grateful.

macrobartfast 2021-03-06T07:43:49.219800Z

super excited to dive into the various parts of this framework now (crux, etc).

blak3mill3r 2021-03-06T07:44:13.220200Z

some cider features don't work...

blak3mill3r 2021-03-06T07:44:43.220900Z

TBH it's been a while since I clojurescripted and I am not sure how much of this is because it's using shadow-cljs ...

blak3mill3r 2021-03-06T07:44:57.221400Z

but the basics work nicely, which is what you wanted!

macrobartfast 2021-03-06T07:45:05.221600Z

it's exactly what I wanted.

macrobartfast 2021-03-06T07:45:19.222200Z

I use very few features (unfortunately)...

macrobartfast 2021-03-06T07:45:27.222500Z

but here the ignorance is an asset.

blak3mill3r 2021-03-06T07:45:38.223Z

haha, I'm glad I could help!

macrobartfast 2021-03-06T07:45:51.223400Z

I am ridiculously glad you could.

macrobartfast 2021-03-06T07:46:01.223800Z

πŸ˜€

blak3mill3r 2021-03-06T07:46:24.224600Z

I am pretty sure I had cider-inspect working with cljs at some point and it is a nice feature, which it seems that the shadow-cljs nREPL server doesn't support even though the cider middleware is loaded

macrobartfast 2021-03-06T07:47:18.225700Z

I'm always on the verge of giving up software altogether, then an awesome person like you or @dpsutton or some other kind soul will step in and get my boat pointed in the right direction again.

macrobartfast 2021-03-06T07:47:30.226Z

So thank you again.

blak3mill3r 2021-03-06T07:58:53.226400Z

Here is some more info, this is important: https://github.com/thheller/shadow-cljs/issues/62

blak3mill3r 2021-03-06T08:00:05.227300Z

essentially it says that the way shadow-cljs works this way at all (i.e. without piggieback) is by emulating (some of) piggieback

blak3mill3r 2021-03-06T08:08:15.228900Z

also relevant discussion here https://github.com/clojure-emacs/cider/issues/2239

blak3mill3r 2021-03-06T08:26:36.232100Z

oh @macrobartfast I just noticed one other potential snag for people trying to use biff with cider+nrepl ... I had a global ~/.nrepl/nrepl.edn file configuring the cider.nrepl/cider-middleware and this appears to break whatever auto-configuration shadow-cljs is doing when it detects that cider-nrepl is on the classpath (as described here: https://shadow-cljs.github.io/docs/UsersGuide.html#nREPL) That is, biff's shadow-cljs nREPL ONLY loads the cider middleware if I remove that ~/.nrepl/nrepl.edn file (which a lot of nrepl users will probably have lying around)

macrobartfast 2021-03-06T08:29:34.232500Z

ok... so many gotchas.

thheller 2021-03-06T08:30:39.233300Z

I'm happy to remove gotchas when someone tells me about them. I don't use cider-nrepl personally so I'm not aware of any issues it may have with shadow-cljs unless someone tells me.

macrobartfast 2021-03-06T08:35:45.235700Z

Totally... and no one could anticipate the issues from all the combinatorial possibilities of all the parts.

macrobartfast 2021-03-06T08:37:23.236Z

What's crazy to me is how often this all just works.

dpsutton 2021-03-06T17:05:33.236100Z

this is all from trying to use biff, which tries to helpfully start everything up and prevents us from putting the necessary dependencies in place. its a bit like lein-shadow where it's trying to be helpful and that means its not super helpful

macrobartfast 2021-03-06T19:00:44.236300Z

I understand... my 'gotchas' was mainly about the whole process of getting biff to work in my setup...

macrobartfast 2021-03-06T19:02:04.236500Z

hopefully when my knowledge increases I might be able to contribute to biff by helping to make a startup option that would enable easier use with Emacs... or at least that seemed like an option that would work...

macrobartfast 2021-03-06T19:03:05.236700Z

for someone like me biff offers a ton of value in being an integrated working system... I can see how all the parts fit together.

macrobartfast 2021-03-06T19:12:48.236900Z

not to mention speed of deployment of ideas I want to explore. But I understand the tradeoffs of any integrated system.