Fork me on GitHub
#cider
<
2019-07-09
>
practicalli-johnny12:07:38

I have new ClojureScript project that runs via the command line and opens up the browser with the ClojureScript app, but doesn't run from Emacs using cider-jack-in-cljs.

error in process filter: Figwheel-main is not available.  Please check 
I created a new project with the Clojure CLI tools and the figwheel-main template (using clj-new). This is the first time with this approach, so I may have missed something.
clj -A:new figwheel-main practicalli/study-group-guide -- --reagent
When I run cider-jack-in-cljs from Emacs, it prompts me for the build tool. I select figwheel-main and then I get the error. The web page does open (assuming because figwheel is not running) Output in message buffer
[nREPL] Starting server via /usr/local/bin/clojure -Sdeps '{:deps {nrepl {:mvn/version "0.6.0"} cider/piggieback {:mvn/version "0.4.1"} refactor-nrepl {:mvn/version "2.5.0-SNAPSHOT"} cider/cider-nrepl {:mvn/version "0.22.0-beta8"}}}' -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware", "cider.piggieback/wrap-cljs-repl"]'...
[nREPL] server started on 40737
[nREPL] Establishing direct connection to localhost:40737 ...
[nREPL] Direct connection to localhost:40737 established
error in process filter: user-error: Figwheel-main is not available. 
I am using the latest version of Cider (updated 12:00 UTC today) and Clojure CLI tools and clj-new Emacs version GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.4) of 2019-06-19 If there is nothing obvious I have missed, I will have a dig around. If I cant get it working, I'll raise a ticket. Thank you.

bozhidar12:07:35

Basically this only checks if the figwheel.main ns in present.

bozhidar12:07:04

Perhaps you didn’t start the right profile or something like this?

practicalli-johnny12:07:08

Will do. It seems to be specific to this project. Other projects that were working, are still working in Emacs / CIDER

practicalli-johnny12:07:23

It doesnt prompt me for a profile. It dies before that

practicalli-johnny12:07:13

Its the first time I have created a project with this template, so will also compare all the configurations to the project that works.

bozhidar12:07:26

I meant the deps.edn profile. It wouldn’t prompt you about this - it just runs whatever the default one is.

practicalli-johnny12:07:04

I get a second prompt when I run a figwheel-main project created from a Leiningen template (I am still figuring out this whole Clojure CLI tools / deps.edn stuff )

practicalli-johnny12:07:45

I am sure I will find something simple missing in the difference between the two project configurations.

practicalli-johnny13:07:42

The only difference I can see is how Leiningen and deps.edn include figwheel-main as a dependency. Leiningen uses :profiles {:dev ,,,} deps.edn uses

:aliases {:fig {:extra-deps
                  {com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}
                   com.bhauman/figwheel-main {:mvn/version "0.1.9"}}

dpsutton13:07:59

the dev profile is used by lein by default so its always there. you'll need to ad the fig profile to the cider startup command. The easiest way is to just prefix before jacking in and adding that profile. there's also cider-clojure-cli-global-options that you can set

practicalli-johnny13:07:47

is there a dir-locals (or what ever its called) approach for this, so I dont forget 🙂

practicalli-johnny13:07:03

I can google for it if you dont have it to hand

dpsutton13:07:36

yeah you can set cider-clojure-cli-global-options i nyour dir locals. set that to "-A:fig"

dpsutton13:07:44

but try it with the prefix to make sure this will fix your issue

practicalli-johnny13:07:45

Yes, just trying to remember how try it with a prefix in Spacemacs 🙂

practicalli-johnny13:07:29

Oops, I killed the classpath... I didnt put the fig profile in quotes

practicalli-johnny13:07:36

SPC u C-c M-J gives me the jack-in command line prompt and when I put -A:fig in the right place straight after the /user/local/bin/clojure command, it works (I put it after -Sdeps first and things went bang 🙂 )

practicalli-johnny13:07:03

[nREPL] Starting server via /usr/local/bin/clojure -A:fig -Sdeps '{:deps {nrepl {:mvn/version "0.6.0"} cider/piggieback {:mvn/version "0.4.1"} refactor-nrepl {:mvn/version "2.5.0-SNAPSHOT"} cider/cider-nrepl {:mvn/version "0.22.0-beta8"}}}' -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware", "cider.piggieback/wrap-cljs-repl"]'...
[nREPL] server started on 35247
[nREPL] Establishing direct connection to localhost:35247 ...
[nREPL] Direct connection to localhost:35247 established

practicalli-johnny13:07:36

I learnt a lot today, thanks @dpsutton and @bozhidar

practicalli-johnny13:07:08

One question. Has clojure-jack-in-cljs command be around for a while? Like more than 6 months? Spacemacs is still using cider-jack-in-clojurescript which as of the latest CIDER beta release seems no longer available - it tells me to use cider-jack-in-cljs instead. Just wanted to be sure I could safely update the Spacemacs Clojure layer with the new command without breaking anyones older setup 🙂

bozhidar13:07:51

@jr0cket At least an year. You can safely update it.

bozhidar13:07:44

A few people complained that the aliases for the jack-in commands were confusing, as they seemed like different jack-in commands, so I’ve decided to trim them all, except the legendary cider-jack-in (which for a while has been an alias for cider-jack-in-clj.

practicalli-johnny13:07:16

Good work. Less commands is definitely easier 🙂

practicalli-johnny13:07:47

The setting in .dir-locals.el is not getting picked up by the cider jack in. Does this look correct

((clojure-mode . ((cider-clojure-cli-global-options . "-A:fig"))))
I assume if the above config is correct, then I have probably just told spacemacs not to load .dir-locals files at some point. I can see the fig alias is missing from jack in command in the message in the status buffer. I created the file following this guide http://endlessparentheses.com/a-quick-guide-to-directory-local-variables.html

practicalli-johnny14:07:44

I switched if off and on again... and it worked !!!

practicalli-johnny14:07:31

Well, I closed all the project files and the layout for that project I had open, then opened the figwheel-main.edn file in another layout and started cider-jack-in-cljs and the alias was picked up in the jack in command from .dir-locals.el

bozhidar14:07:22

@jr0cket a buffer has to be recreated for the vars to go in effect.

bozhidar14:07:39

I recall there was also some command to refresh them, but I don’t remember what was its name.

felipebarros22:07:25

revert-buffer I believe.

dpsutton15:07:48

hack-local-variables?

bozhidar16:07:41

@dpsutton It’s a function, not a command, but yeah - I was thinking of it.

macrobartfast16:07:50

I just found the awesome cider browse ns feature... thank you for that! I use evil-mode... any suggestions for overriding those bindings in vanilla terminal emacs? in particular, would like to be able to jump to definition with the 's' key which evil has reserved.

dpsutton16:07:42

try cider-apropos 🙂

macrobartfast16:07:07

ok... will take a look.

macrobartfast16:07:11

cider-apropos looks good... however, I definitely like the straightforward list of cider-browse-ns-all... ideally I would like to just move the pointer up and down that list and see the declaration in the other window like cider-browse-ns-find-at-point, ideally without leaving the list, but that probably doesn't exist quite like that.

macrobartfast16:07:08

I guess it's really just about dropping into a ns or project and being able to see what it's about on a functional level and peruse it.

macrobartfast16:07:33

which there may be better approaches to than I'm thinking of.

practicalli-johnny18:07:56

I don't really navigate that much around a project namespace, as most of my namespaces are relatively small (certainly compared to my previous Java projects). I jump around a lot using Evil mode and avvy and on larger namespaces I may use code folding. Here is a selection of what I currently do https://practicalli.github.io/spacemacs/navigating-code/

dpsutton18:07:42

"jump to first unbalanced parens" that is crazy to me 🙂

felipebarros18:07:55

@jr0cket recently I stumbled upon the same block with the figwheel-main alias. Others will probably be blocked by it too since, as you stated, C-u C-c M-J borks if you insert -R:fig or -A:fig at the end, so even the solution has this little nitpick. Where would be the right place to explain this detail @bozhidar?

dpsutton18:07:29

it needs to be a well-formed clj incantation. is that really CIDER documentation required? You're editing the raw clj form

practicalli-johnny18:07:07

@anantpaatra I'll be adding what I have learnt to my (one day I will finish it) book on Spacemacs

😄 4
💪 4
felipebarros18:07:49

I feel it ends up being a little counter intuitive because CIDER injects a lot of things in the string and you are given the minibuffer with point at the end of it. I for once had tried the solution but still had to ask around to actually get that it wouldn't support it.

practicalli-johnny18:07:29

I enjoyed breaking my classpath, but then I am not on a deadline or just starting with ClojureScript. I am happy to do a pull request to the already excellent http://docs.cider.mx

🎉 4
dpsutton18:07:33

it used to present a kinda custom editor. I chose to change it to the raw command so it was clear where things can go. Its just a clj or lein invocation

dpsutton18:07:41

happy to have better docs all the time though 🙂

Casey20:07:06

how do I move the cider repl window so it is on the right side with a horizontal split rather than the default wide-and-short vertical split on the bottom?

practicalli-johnny23:07:53

I only know for Spacemacs Evil normal mode, which is SPC w l or SPC w L

theeternalpulse21:07:55

I think you can check out window dedication. It's been driving me crazy as of late and I am going to look into that. I get the issue where I connect to cider and it replaced my current window split, rather then move to another one.

practicalli-johnny01:07:19

@U70QFSCG2 As mentioned, window purpose is probably what you want if you have a need to control window placement based on buffer type https://github.com/bmag/emacs-purpose I never use the REPL buffer myself and Spacemacs doesn't open that buffer in a window by default. Evaluating in the source code buffer is much more effective for me.

Casey20:07:23

i'm using evil, and my normal window moving commands don't seem to affect the repl window