Hey Borkdude I just rewrote my https://github.com/rafaeldelboni/dotfiles/tree/master/config/i3blocks/scripts using babashka instead of bash and is incredible, thanks a lot for all your work and enabling us to move out the ugly bashscripts 😄
🎉 thanks for sharing :)
damn, this is cool 🙂
Btw, feel free to post it here: https://github.com/babashka/babashka/discussions/categories/show-and-tell I think the Github Discussions board can be a nice place to share this stuff as well.
Did anything cool with babashka? Consider sharing it here: https://github.com/babashka/babashka/discussions/categories/show-and-tell
Ah ok I will, thanks
I'm a getting a stack trace as the result of a function chain, but no idea in where / which function it has occurred. Is there a way to improve it ?
#error {
:cause nil
:via
[{:type java.lang.NullPointerException
:message nil
:at [clojure.lang.Numbers ops Numbers.java 1068]}]
:trace
[[clojure.lang.Numbers ops Numbers.java 1068]
[clojure.lang.Numbers isZero Numbers.java 117]
[clojure.core$zero_QMARK_ invokeStatic core.clj 874]
[clojure.core$zero_QMARK_ invoke core.clj 869]
[sci.impl.analyzer$return_call$fn__18447 invoke analyzer.cljc 811] etc...
@dennisa when you invoke the script from the command line you will likely get a better error message
also the exception should probably have a line and column number
and file name
in CLI, but not in the Repl?
if not, repro welcome
yes
are you using the nREPL btw? please provide as much info as you can about your environment
#error {
:cause nil
:via
[{:type java.lang.NullPointerException
:message nil
:at [clojure.lang.Numbers ops Numbers.java 1068]}]
:trace
[[clojure.lang.Numbers ops Numbers.java 1068]
[clojure.lang.Numbers isZero Numbers.java 117]
[clojure.core$zero_QMARK_ invokeStatic core.clj 874]
[clojure.core$zero_QMARK_ invoke core.clj 869]
[sci.impl.analyzer$return_call$fn__18447 invoke analyzer.cljc 811]
[sci.impl.evaluator$eval invokeStatic evaluator.cljc 390]
[sci.impl.analyzer$return_if$fn__18211 invoke analyzer.cljc 462]
[sci.impl.evaluator$eval invokeStatic evaluator.cljc 390]
[sci.impl.evaluator$eval invoke evaluator.cljc 385]
[sci.impl.evaluator$eval_let$fn__17163 invoke evaluator.cljc 68]
[sci.impl.evaluator$eval_let invokeStatic evaluator.cljc 62]
[sci.impl.analyzer$expand_let_STAR_$fn__18173 invoke analyzer.cljc 338]
[sci.impl.evaluator$eval invokeStatic evaluator.cljc 390]
[sci.impl.evaluator$eval invoke evaluator.cljc 385]
[sci.impl.evaluator$eval_try invokeStatic evaluat
or.cljc 133]
[sci.impl.evaluator$eval invokeStatic evaluator.cljc 403]
[sci.impl.analyzer$return_do$fn__17612 invoke analyzer.cljc 117]
[sci.impl.evaluator$eval invokeStatic evaluator.cljc 390]
[sci.impl.evaluator$eval invoke evaluator.cljc 385]
[sci.impl.fns$fun$arity_4__16544 invoke fns.cljc 149]
[sci.impl.vars.SciVar invoke vars.cljc 321]
[sci.impl.analyzer$return_call$fn__18453 invoke analyzer.cljc 811]
[sci.impl.evaluator$eval invokeStatic evaluator.cljc 390]
[sci.impl.evaluator$eval invoke evaluator.cljc 385]
[sci.impl.evaluator$eval_let$fn__17163 invoke evaluator.cljc 68]
[sci.impl.evaluator$eval_let invokeStatic evaluator.cljc 62]
[sci.impl.analyzer$expand_let_STAR_$fn__18173 invoke analyzer.cljc 338]
[sci.impl.evaluator$eval invokeStatic evaluator.cljc 390]
[sci.impl.evaluator$eval invoke evaluator.cljc 385]
[sci.impl.fns$fun$arity_2__16520 invoke fns.cljc 141]
[sci.impl.vars.SciVar invoke vars.cljc 317]
[sci.impl.analyzer$return_call$fn__18449 invoke analyzer.cljc 8
11]
[sci.impl.evaluator$eval invokeStatic evaluator.cljc 390]
[sci.impl.interpreter$eval_form invokeStatic interpreter.cljc 77]
[sci.core$eval_form invokeStatic core.cljc 257]
[babashka.nrepl.impl.server$eval_msg$fn__30614 invoke server.clj 44]
[babashka.nrepl.impl.server$eval_msg invokeStatic server.clj 32]
[babashka.nrepl.impl.server$session_loop invokeStatic server.clj 223]
[babashka.nrepl.impl.server$listen$fn__30688 invoke server.clj 264]
[sci.impl.vars$binding_conveyor_fn$fn__8727 invoke vars.cljc 147]
[clojure.core$binding_conveyor_fn$fn__5773 invoke core.clj 2034]
[clojure.lang.AFn call AFn.java 18]
[java.util.concurrent.FutureTask run FutureTask.java 264]
[java.util.concurrent.ThreadPoolExecutor runWorker ThreadPoolExecutor.java 1128]
[java.util.concurrent.ThreadPoolExecutor$Worker run ThreadPoolExecutor.java 628]
[java.lang.Thread run Thread.java 834]
[com.oracle.svm.core.thread.JavaThreads threadStartRoutine JavaThreads.java 519]
[com.oracle.svm.core.posix.thread.Pos
ixJavaThreads pthreadStartRoutine PosixJavaThreads.java 192]]}
yes, nrepl connected from Calva in VSC on the mac; the trace in thread above
so the issue is likely that you are calling zero?
on a nil
value
but you probably already guessed this
when invoking the script from the command line you will get a proper stack trace from bb itself
but the nrepl environment doesn't have this yet, I think
Yes, searching in the editor for zero? :))
when I evaluate:
(defn foo []
(zero? nil))
(foo)
I see
clojure.lang.ExceptionInfo: null
{:type :sci/error, :line 4, :column 3, :message nil, :sci.impl/callstack #object[clojure.lang.Delay 0x4e72f87f {:status :pending, :val nil}], :file "\n\n(defn foo []\n (zero? nil))\n", :locals {}}
as the first linesand this gives you some clue where to look, usually
but with the command line get:
$ bb /tmp/foo.clj
----- Error --------------------------------------------------------------------
Type: java.lang.NullPointerException
Location: /tmp/foo.clj:4:3
----- Context ------------------------------------------------------------------
1:
2:
3: (defn foo []
4: (zero? nil))
^---
5:
6: (foo)
----- Stack trace --------------------------------------------------------------
clojure.core/zero? - <built-in>
user/foo - /tmp/foo.clj:4:3
user/foo - /tmp/foo.clj:3:1
user - /tmp/foo.clj:6:1
which is much better
is there a way I can impove it on my end in repl? : )
I don't think so, at the moment
Is there some Babashka-compatible templating engine for Clojure?
When I say templating engine, I mean for instance ERB in Ruby (`<%= eval_expr(whatevs) %>`) or <?php
in PHP.
What I'm trying to do: I have a README template which is inherits a lot of data from the monorepo's README, but needs substituting some project-specific stuff.
@jakub.stastny.pt_serv babashka has Selmer built-in :)
Great! Thanks @borkdude!