This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-04
Channels
- # announcements (123)
- # asami (1)
- # babashka (50)
- # beginners (49)
- # biff (21)
- # calva (48)
- # cider (6)
- # clj-yaml (8)
- # cljsrn (2)
- # clojure (9)
- # clojure-conj (1)
- # clojure-indonesia (1)
- # clojure-losangeles (1)
- # clojure-uk (18)
- # clojurescript (21)
- # data-science (19)
- # datahike (13)
- # events (1)
- # fulcro (1)
- # honeysql (4)
- # hyperfiddle (40)
- # improve-getting-started (3)
- # inf-clojure (1)
- # malli (6)
- # off-topic (45)
- # releases (3)
- # rewrite-clj (14)
- # scittle (1)
- # shadow-cljs (57)
- # tools-deps (1)
- # vim (13)
- # xtdb (14)
Hi folks. I'm trying to use Calva's debugger to teach someone who's learning Clojure the order of execution of code, which means I'd like to step through as much as possible. How can I instrument every fn and keep them instrumented? Is there any way to instrument Clojure core fns, too (I see the docs say it's not doable, but I want to check if it's just cumbersome or not doable)? Or perhaps does someone have a better recommendation for a Clojure debugger or tracer?
I don't quite understand why we can't instrument clojure core functions, so can't comment on how doable it is. I think that would be quite awesome to be able to do.
As for alternatives. The Cursive debugger is the best traditional debugger for Clojure that I know of. For your purposes though, maybe a tracer like @U02EMBDU2JU’s omni-trace would be a good fit? https://github.com/Cyrik/omni-trace Lukas demoed it at ClojureD 2022: https://www.youtube.com/watch?v=JitNGtiuNOA
I've mostly switched to using https://github.com/jpmonettas/flow-storm-debugger since I don't have the time to work on omni-trace right now
I suppose the core fns don't work because of direct linking. All of core is compiled with that, which means no var indirection, which means no instrumentation. Should be able to get a core lib with that disabled though.
Just tried out flow-storm-debugger. It's a nice tool. The key difference between it and Calva's debugger is that flow-storm-debugger shows what happened after the fact. It doesn't allow you to step through code yourself; it shows you what code was stepped through when you ran it previously.
I never realized that Clojure was so lacking in the debugging world, since we all just use our REPLs and generally understand the flow of execution. But for someone learning Clojure as a first language, that really doesn't cut it. Makes me realize that jank can bring big wins here with some out of the box DAP tooling.
To me it seems like showing a beginner the flow using flow-storm after execution is just as good, if not better, than showing it during execution, since you can step backwards in time too. I think showing a beginner how to use inline defs to be able to execute any part of the code in question at will is also probably pretty important. I added much of the debugger functionality to Calva when I was still fairly new to Clojure, but I don’t even use it (or any debugger). I do think it might be a good idea for me to try using something like flow-storm more in some situations, but so far I don’t really feel a need for something like that. It could be the case that I just don’t know what I’m missing, though.
I've just gotten used to having it in my dev deps and staring it with a hot key if I'm doing something that could use it.
I have a question about using Calva (in VSCode) with a deps.edn project. Untill now all projects I worked on were based on leiningen, easy to use but much overhead.
I migrated one of my projects to deps.edn and I can run it and it works with clj -M -m myapp.core
.
But when I Jack-In with Calva to start a repl, the app and its dependencies are not on the classpath. First I have to do a (require 'myapp.core)
before anything works, is that normal?
Second, I added a new dependency and now I get a message that this dep is not located anywhere on the classpath. What might I be doing wrong?
Hard to tell without knowing more about the project structure. Can you describe it a bit?
Here's a quick repo, will delete it when youre done https://github.com/LouDnl/yls-pez
I can't easily test this because postgres and possibly other things. There is nothing that strikes me as wrong at a glance. (I would remove the nrepl dependencies from the project unless they are needed for something else than editor tooling.) Can you describe the steps you take to start, and what you expect should happen?
The nrepl deps are needed for the repl namespace.
Steps:
Open VSCode project
Jack-In choosing the project root
Select dev and calva aliases
Wait for repl clj:user:>
(require 'youless.core)
Try to start statemanagement:
; Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:476).
; mount.lite
or require:
(require 'youless.core)
; Execution error (FileNotFoundException) at youless.config/eval7237$loading (config.clj:1).
; Could not locate taoensso/timbre__init.class, taoensso/timbre.clj or taoensso/timbre.cljc on classpath.
@U0ETXRFEW you can test it without postgres, I cant even get a namespace after jackin without starting the project using mount.lite
I had an error in the :dev alias that overrided the main deps, so thats solved. I used :deps instead of :extra-deps.
But that still doesnt explain why I need to do (require 'youless.core)
first?
Calva does not require anything for you, so if your project needs a special order of requires, it could be that you need to require some namespace before some other for things to work. In this case it seems like it is unintended so I would go from the error messages you get and see what might be missing in your ns forms.
Also have a look at the leiningen project to see if it had some init-fn configured our something. Might give some clues to what you need to do with the deps project to make it work.
I think what I am missing are the deps.edn equivalents of project.clj's :
:main youless.core
:aot [youless.core]
@U0ETXRFEW I think I solved it by using "afterCLJReplJackInCode": "(require 'youless.core)",
in my custom calva.replConnectSequences
You don't need any :calva
alias if you are using jack-in, btw. Jack-in will override those (as well as the global nrepl dependencies you have there.)
https://code.visualstudio.com/blogs/2022/10/04/vscode-community-discussions There’s a link on this page near the bottom, and there’s also a link to the VS Code community GH discussions.