calva

Wednesdays you might find @U0ETXRFEW in the Gather Calva space. Invite is https://gather.town/invite?token=GZqrm7CR and the password is `Be kind`.
lambdam 2020-09-16T08:34:29.251700Z

Hello, I am discovering Calva (coming form Spacemacs). Launching and connecting to a REPL works well but jack-in doesn't :

> Executing task: clojure -Sdeps '{:deps {nrepl {:mvn/version "0.6.0"} cider/cider-nrepl {:mvn/version "0.23.0"} clj-kondo {:mvn/version "2020.04.05"}}}'  -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" <

zsh:1: command not found: clojure
The terminal process "/usr/bin/zsh '-c', 'clojure -Sdeps '{:deps {nrepl {:mvn/version "0.6.0"} cider/cider-nrepl {:mvn/version "0.23.0"} clj-kondo {:mvn/version "2020.04.05"}}}'  -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"'" failed to launch (exit code: 127).

Terminal will be reused by tasks, press any key to close it.
But when I launch a terminal from VSCode, clojure is found:
$ which clojure
/home/dam/.asdf/shims/clojure
As shown, I'm using asdf package manager. Is it a known issue? Does someone someone has a clue to fix this? Thanks

borkdude 2020-09-16T08:35:45.252400Z

@dam You could try launching VSCode from your terminal. You can install a CLI program called code from within VSCode which you can then launch in the terminal

borkdude 2020-09-16T08:36:17.253100Z

Search in the command palette "install command line" or something similar

lambdam 2020-09-16T08:37:39.254Z

Ohh thanks. I works. I installed VSCodium on Linux Mint so I had codium in my PATH.

lambdam 2020-09-16T08:40:12.255600Z

Still, it feels weird that I have to do that (I usually launch apps with the "rofi" app launcher). Emacs doesn't have this problem. Is it linked with the Electron app?

2020-09-16T08:40:43.256Z

this is a recurring issue with a number of apps

2020-09-16T08:41:13.256500Z

depending on the distribution if you augment your PATH in an appropriate location, it should take care of itself

2020-09-16T08:41:20.256900Z

in my case i do this in ~/.profile

2020-09-16T08:42:01.257700Z

it looks like you use zsh, so it might be good to figure out an appropriate file to modify -- sometimes this is impacted by your particular distribution

borkdude 2020-09-16T08:43:00.258400Z

I think I put env vars in .zshenv

2020-09-16T08:44:30.259100Z

if that doesn't work might consider these types of discussions: https://www.reddit.com/r/linuxmint/comments/6d9bw6/which_files_cinnamon_source_on_start/

2020-09-16T08:45:18.260Z

afaik, this can depend on one's distribution and possibly some other factors

lambdam 2020-09-16T08:50:38.260200Z

Thanks a lot.

lambdam 2020-09-16T08:52:28.260700Z

I didn't try with Cinnamon yet. I use Awesome WM on top of Linux Mint.

lambdam 2020-09-16T08:52:41.261Z

But I'll try with Cinnamon later.

2020-09-16T08:55:34.261800Z

i think it's worth trying what borkdude mentioned first. wouldn't want to steer you away from awesome wm -- nice choice btw πŸ™‚

lambdam 2020-09-16T09:02:42.265200Z

Also I'm mixing Calva with Parinfer and Parinfer doesn't seem to work properly. I usually use Paredit with Spacemacs so I don't know the precise behaviour of Parinfer in all cases. Are there known conflicting behaviours between those two packages? I'm looking for an easy setup to start coding with Clojure, to make discover Clojure to some friends (and really, the biggest problem is parenthesis management).

2020-09-16T09:10:57.265600Z

wrt parinfer / paredit, i think the official recommendation is close to this: https://calva.io/paredit/

2020-09-16T09:13:15.266800Z

i think @pez or @brandon.ringe would know better about potential conflicts

teawaterwire 2020-09-16T09:36:57.268Z

i'm not sure i remember - but does Calva provide autocomplete (ie when typing re-frame.core/ it will show me options) -- it seems it's only displaying the symbol in the file that's open?

pez 2020-09-16T09:54:26.269200Z

It should show you the options cross files. Sometimes you might need to load the current file.

1πŸ‘
pez 2020-09-16T09:57:02.271900Z

I think that all I know about conflicts between Calva and parinfer, I have written down at http://calva.io. I'd say that you don't need parinfer with Calva, at least not if you are on friendly footing with paredit.

0xclj 2020-09-16T10:45:29.275200Z

Hi, does calva intercept the http requests? Reading the docs, my understanding is that the function to be debugged has to be explicitly called from vscode itself. Is that right?

0xclj 2020-09-17T07:17:41.283200Z

Hey @brandon.ringe, thanks for the response. Am I doing something wrong here?

bringe 2020-09-17T16:11:12.284800Z

Hmm are you using Calva's jack-in to start your repl? Jack-in injects cider-nrepl and the cider-nrepl middleware as a dependency, which is used for some of Calva's functionality, including the debugger. The reader function for tag #break is defined by cider-nrepl (or maybe the middleware).

bringe 2020-09-17T16:11:51.285300Z

So if you started a repl outside of Calva and connected to it, you may not have the right dependencies there, hence the error

bringe 2020-09-17T16:23:46.285600Z

So, if you are using jack-in, a couple of other things could be happening. It could be the case that with ring/compojure these breakpoints don't work well for some reason (I tested this in a pedestal service), for reasons I don't know. It could also possibly be something with AOT compilation or something, though just guessing there. If you can provide a repo for reproducing the problem (like your sample code there in a repo I can pull down), then I'll look more into it. Thanks for the video and feedback thus far.

0xclj 2020-09-17T16:32:36.285800Z

I'm not sure if lein run 8888 has anything to do with it. I did try again by jacking in; resulting nREPL server started on port 52278 on host 127.0.0.1 - <nrepl://127.0.0.1:52278> but the results are still the same. Could be dependency issues like you mentioned; I'm just a week into Clojure now, so could very well be something I'm not be doing right as well. I'll share the repo in a while. Thanks!

1πŸ‘
bringe 2020-09-17T17:10:50.286Z

Yeah that lein run command surely would not include the right deps. Weird that jacking in didn't fix it though. I'll look more into it with your example repo.

bringe 2020-09-17T17:32:54.286300Z

Also your feedback as a Clojure beginner is very valuable, and much appreciated :simple_smile: . It helps us to fix docs or functionality that may not be as friendly as we hoped for beginners. It's hard to put yourself in beginners' shoes once you've been in the mix for a while and potentially developed unconscious habits that work around shortcomings.

pez 2020-09-16T13:31:38.277Z

I’m not ignoring you @mail.acharyarahul.now πŸ˜ƒ Just that I’m not in the know with the debugger as much as @brandon.ringe is. Let’s see what his take is. It could also be a cider-nrepl thing.

pez 2020-09-16T14:33:18.277600Z

Apropos theming, here’s a Calva-ish slack sidebar theme:

pez 2020-09-16T14:33:19.277800Z

#5D85D4,#A37648,#75AD48,#FCFFFF,#D1975C,#FAFEFE,#F1F4F4,#D1975C

0xclj 2020-09-16T15:10:22.277900Z

Cool! Thank you πŸ˜€

ryan echternacht 2020-09-16T16:10:04.278300Z

can that blue be darker

ryan echternacht 2020-09-16T16:10:09.278500Z

it's really bright

bringe 2020-09-16T16:10:26.278600Z

Unfortunately I don't think breakpoints work inside API routes when called externally. At least, I've experienced this myself too iirc. I think it has something to do with how cider-nrepl handles breakpoints and the way the code is executed in each case, since we're mostly deferring to it for that part of things.

bringe 2020-09-16T16:10:49.278800Z

I'll try to find more info though. This is the first time someone mentioned this since I discovered it πŸ˜„

bringe 2020-09-16T16:11:14.279Z

One thing you can do though is call your endpoints from the REPL, as if you were testing them as pure functions.

pez 2020-09-16T16:19:33.279700Z

#3667C9,#A37648,#75AD48,#FCFFFF,#D1975C,#FAFEFE,#F1F4F4,#D1975C

bringe 2020-09-16T16:21:00.279800Z

OH, another reason your breakpoint would not be hit in request-info is that cider-nrepl doesn't break it certain situations that seem unnecessary. Like if you put a #break before the map in request-info and that's all that's in that function, it won't be hit, even when running it from the repl

bringe 2020-09-16T16:21:50.280Z

If you had a println call or placed the breakpoint before some operation inside the map, it would break

pez 2020-09-16T16:24:24.280500Z

Google ”rgb to hex” to get a nice UI to paste the values in and fiddle with brightness (in the below version I used the HSL-entry, since the last parameter can be moved adjusting only brightness).

bringe 2020-09-16T16:27:21.280700Z

https://calva.io/debugger/#my-breakpoint-isnt-being-hit See here. I may need to add something about breakpoints and calling endpoints externally

bringe 2020-09-16T16:31:56.281Z

Oh wait... good news... it appears breakpoints do work in API endpoints when called externally. I just called my test-endpoint above using postman, with the breakpoint in the headers map before an operation, and it paused execution there. I actually thought this didn't work until now, so thanks πŸ˜„. Let me know if you have issues though, and remember you may need to evaluate the form itself with alt+enter for the breakpoint to work (given it's in a debuggable spot). Another thing you may find useful for debugging, besides using println, is using an inline def. You could call (def req request) inside your endpoint and then after you call it, you can examine the contents of req, perform operations on it, etc., in the repl.

ryan echternacht 2020-09-16T19:05:20.281400Z

ooo, much better. thanks!

ryan echternacht 2020-09-16T19:07:46.281500Z

Yeah, I realized after posting that, I was being a bit of a baby. Thanks for the new colors tho!

pez 2020-09-16T19:37:55.282900Z

Haha, I did not think you were being a bit of a baby!