Fork me on GitHub
#calva
<
2020-09-16
>
lambdam08:09:29

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

borkdude08:09:45

@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

borkdude08:09:17

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

lambdam08:09:39

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

lambdam08:09:12

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?

sogaiu08:09:43

this is a recurring issue with a number of apps

sogaiu08:09:13

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

sogaiu08:09:20

in my case i do this in ~/.profile

sogaiu08:09:01

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

borkdude08:09:00

I think I put env vars in .zshenv

sogaiu08:09:18

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

lambdam08:09:38

Thanks a lot.

lambdam08:09:28

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

lambdam08:09:41

But I'll try with Cinnamon later.

sogaiu08:09:34

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

lambdam09:09:42

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).

sogaiu09:09:57

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

sogaiu09:09:15

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

teawaterwire09:09:57

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?

pez09:09:26

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

👍 3
pez09:09:02

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.

0xclj10:09:29

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?

0xclj11:09:05

Further details: I have this file(WIP) from practicalli guides. When I run the server and send a request to /request-info from the browser and have the breakpoint inside request-info , nothing really happens. In fact, if I place #break ; it errors out. So, what's the recommended way to debug here?

bringe16:09:26

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.

bringe16:09:49

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

bringe16:09:14

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

bringe16:09:00

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

bringe16:09:50

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

bringe16:09:21

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

bringe16:09:56

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.

0xclj07:09:41

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

bringe16:09:12

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).

bringe16:09:51

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

bringe16:09:46

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.

0xclj16:09:36

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 - 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!

👍 3
bringe17:09:50

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.

bringe17:09:54

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.

0xclj11:09:05

Further details: I have this file(WIP) from practicalli guides. When I run the server and send a request to /request-info from the browser and have the breakpoint inside request-info , nothing really happens. In fact, if I place #break ; it errors out. So, what's the recommended way to debug here?

pez13:09:38

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.

0xclj15:09:22

Cool! Thank you 😀

pez14:09:18

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

pez14:09:19

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

ryan echternacht16:09:04

can that blue be darker

pez16:09:24

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).

ryan echternacht19:09:46

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

pez19:09:55

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

ryan echternacht16:09:09

it's really bright

pez16:09:33

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

ryan echternacht19:09:20

ooo, much better. thanks!