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@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
Search in the command palette "install command line" or something similar
Ohh thanks. I works.
I installed VSCodium on Linux Mint so I had codium
in my PATH.
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?
this is a recurring issue with a number of apps
depending on the distribution if you augment your PATH in an appropriate location, it should take care of itself
in my case i do this in ~/.profile
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
I think I put env vars in .zshenv
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/
afaik, this can depend on one's distribution and possibly some other factors
Thanks a lot.
I didn't try with Cinnamon yet. I use Awesome WM on top of Linux Mint.
But I'll try with Cinnamon later.
i think it's worth trying what borkdude mentioned first. wouldn't want to steer you away from awesome wm -- nice choice btw π
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).
wrt parinfer / paredit, i think the official recommendation is close to this: https://calva.io/paredit/
i think @pez or @brandon.ringe would know better about potential conflicts
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?
It should show you the options cross files. Sometimes you might need to load the current file.
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.
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?
Hey @brandon.ringe, thanks for the response. Am I doing something wrong here?
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).
So if you started a repl outside of Calva and connected to it, you may not have the right dependencies there, hence the error
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.
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!
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.
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.
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.
Apropos theming, hereβs a Calva-ish slack sidebar theme:
#5D85D4,#A37648,#75AD48,#FCFFFF,#D1975C,#FAFEFE,#F1F4F4,#D1975C
Cool! Thank you π
can that blue be darker
it's really bright
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.
I'll try to find more info though. This is the first time someone mentioned this since I discovered it π
One thing you can do though is call your endpoints from the REPL, as if you were testing them as pure functions.
#3667C9,#A37648,#75AD48,#FCFFFF,#D1975C,#FAFEFE,#F1F4F4,#D1975C
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
If you had a println
call or placed the breakpoint before some operation inside the map, it would break
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).
https://calva.io/debugger/#my-breakpoint-isnt-being-hit See here. I may need to add something about breakpoints and calling endpoints externally
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.
ooo, much better. thanks!
Yeah, I realized after posting that, I was being a bit of a baby. Thanks for the new colors tho!
Haha, I did not think you were being a bit of a baby!