This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-20
Channels
- # announcements (16)
- # babashka (71)
- # beginners (121)
- # bristol-clojurians (2)
- # calva (55)
- # clj-kondo (16)
- # clojure (103)
- # clojure-europe (9)
- # clojure-italy (5)
- # clojure-nl (4)
- # clojure-spec (49)
- # clojure-uk (57)
- # clojurescript (28)
- # conjure (9)
- # cursive (6)
- # datascript (3)
- # datomic (35)
- # duct (20)
- # events (3)
- # figwheel-main (12)
- # fulcro (6)
- # graalvm (12)
- # juxt (3)
- # kaocha (5)
- # lumo (10)
- # malli (5)
- # off-topic (54)
- # pathom (8)
- # re-frame (19)
- # reitit (21)
- # remote-jobs (1)
- # shadow-cljs (102)
- # sql (38)
- # tools-deps (60)
- # uncomplicate (3)
- # xtdb (10)
$ cat /tmp/foo.clj
(defn foo []
(+ 1 2 :foo))
(foo)
$ bb -f /tmp/foo.clj
java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.Number [at /tmp/foo.clj, line 7, column 3]
3:
4:
5:
6: (defn foo []
7: (+ 1 2 :foo))
^--- clojure.lang.Keyword cannot be cast to java.lang.Number [at /tmp/foo.clj, line 7, column 3]
8:
9: (foo)
Stacktrace:
clojure.core/+ - <built-in>
user/foo - /tmp/foo.clj:7:3
user/foo - /tmp/foo.clj:6:1
user - /tmp/foo.clj:9:1
Some polishing needed, but getting there.Some things to consider: - Should we only show the context with the error message and not the first line which contains the same error message? - Should we show the stacktrace by default or write it to a temp .edn file like clojure does?
The formatting is helpful and reminds me of what I saw from shadow-cljs warnings when testing rewrite-cljc against shadow-cljs.
Did not quickly find one on web, so turned on deprecation warnings for rewrite-cljc here’s a sample:
Ya, the coloring is interesting. Also inspired by shadow-cljs, might consider not repeating filename and line number in contextual message?
7: (+ 1 2 :foo))
^--- clojure.lang.Keyword cannot be cast to java.lang.Number [at /tmp/foo.clj, line 7, column 3]
could be:
7: (+ 1 2 :foo))
^--- clojure.lang.Keyword cannot be cast to java.lang.Number
I’ll try triggering a stack trace under shadow-cljs and see if it can offer inspiration there as well…
Hmm… not sure… I’m only using shadow-cljs to to run unit tests… maybe somebody more familiar with shadow-cljs can give a stack trace example.
Yes, that was the initial inspiration, jeroenvandijk did the initial implementation based on that
Yeah good example first thing in README https://github.com/bhauman/figwheel-main/blob/master/README.md
As to your question: > - Should we only show the context with the error message and not the first line which contains the same error message?
I think the first line is just saying pretty much the same thing as the contextual message and does not add value.
And as to: > - Should we show the stacktrace by default or write it to a temp .edn file like clojure does?
I’m not sure. If the stack trace is huge and scrolls the summary off the screen, that would make the details hide the summary. But you had the idea of maybe only showing the first 5 and last 5 items, so maybe that would solve that? But what if you really need the full trace? I was initially annoyed by the change in clojure to write the stack trace to an edn file, but then got over it quickly when I realized they also added the --report
option.
So I guess the question is, is the contextual message typically enough info, and the stack trace typically noise?
I think it's useful to know where things started and ended. The part in the middle is usually not that interesting
Am I right in thinking-out-loud that: for clojure one goal is to make it easy for tooling to take advantage of and use data it spits out to provide a good experience for the user. This would also be true for babashka as well, but babashka being a scripting tool, is used stand-alone and should provide some of the niceties that clojure does not want to concern itself with. Hence your contextual message.
One thing I'd like to do different with babashka is spit out file locations that you can click on (either in terminal or emacs) so it will point you to the right file.
I guess we can have both: spit out data and show useful information. We can do the data bit later if people want it, but I don't expect it.
As I ramble away, I’m thinking what I would like would be terse by default (I think the context message would be all I need usually), with an option to be less terse (maybe adds your 5/5 stack trace with context for each item), and then an option to be fully verbose (full stack trace with context for every item). I wonder what other folks think? (hint hint others! ). And maybe I would not really need the middle option. Terse or fully verbose might do.
With stack traces I most often use the first few lines up to the first project specific frame that isn’t some sort of helper function.
First few lines: is that beginning at the point of error? e.g.:
(defn foo [] (/ 1 0)) (foo)
Will now print:
java.lang.ArithmeticException: Divide by zero [at <expr>, line 1, column 14]
1: (defn foo [] (/ 1 0)) (foo)
^--- Divide by zero [at <expr>, line 1, column 14]
Stacktrace:
clojure.core// - <built-in>
user/foo - <expr>:1:14
user/foo - <expr>:1:1
user - <expr>:1:23
Wow, that looks good! the stacktrace seems superfluous in that example. By first I meant deepest. The highest level frames are usually only interesting in multi-threaded code. In general errors are either implementation errors or errors in how something is being called. Both tend to lie in project specific code, so a stack trace that doesn’t show a project specific frame is usually not very helpful.
Here's another example with a bigger stacktrace:
$ export BABASHKA_CLASSPATH=$(clojure -Spath -Sdeps '{:deps {borkdude/spartan.spec {:git/url "" :sha "ff7317d67ec15f188afb856d37090e5c9509374e"}}}')
$ bb -e "(defn f [_] (/ 1 0)) (require '[spartan.spec :as s]) (s/explain (s/cat :x int? :y f) [1 #{:foo}])"
java.lang.ArithmeticException: Divide by zero [at <expr>, line 1, column 13]
1: (defn f [_] (/ 1 0)) (require '[spartan.spec :as s]) (s/explain (s/cat :x int? :y f) [1 #{:foo}])
^--- Divide by zero [at <expr>, line 1, column 13]
Stacktrace:
clojure.core// - <built-in>
user - <expr>:1:13
spartan.spec/dt local: pred - /Users/borkdude/.gitlibs/libs/borkdude/spartan.spec/ff7317d67ec15f188afb856d37090e5c9509374e/src/spartan/spec.clj:604:5
spartan.spec/dt - /Users/borkdude/.gitlibs/libs/borkdude/spartan.spec/ff7317d67ec15f188afb856d37090e5c9509374e/src/spartan/spec.clj:611:16
spartan.spec/dt - /Users/borkdude/.gitlibs/libs/borkdude/spartan.spec/ff7317d67ec15f188afb856d37090e5c9509374e/src/spartan/spec.clj:602:8
...
spartan.spec/explain-out - /Users/borkdude/.gitlibs/libs/borkdude/spartan.spec/ff7317d67ec15f188afb856d37090e5c9509374e/src/spartan/spec.clj:279:16
spartan.spec/explain-out - /Users/borkdude/.gitlibs/libs/borkdude/spartan.spec/ff7317d67ec15f188afb856d37090e5c9509374e/src/spartan/spec.clj:269:1
spartan.spec/explain - /Users/borkdude/.gitlibs/libs/borkdude/spartan.spec/ff7317d67ec15f188afb856d37090e5c9509374e/src/spartan/spec.clj:279:3
spartan.spec/explain - /Users/borkdude/.gitlibs/libs/borkdude/spartan.spec/ff7317d67ec15f188afb856d37090e5c9509374e/src/spartan/spec.clj:276:1
user - <expr>:1:54
If you want to test it out, there's binaries in #babashka_circleci_builds from the issue-508-free-st
branch
On the JVM, jdbc requires a native dependency (`sqljdbc_auth.dll`) to connect to SQL Server via "Integrated Authentication". Does that sound like something can work with Babashka?
@isak Loading native libraries works, also in GraalVM, but that needs to be built into babashka or a babashka pod. We have babashka pods for several database flavors: https://github.com/babashka/babashka-sql-pods. As of now there is no SQL Server pod.
So contributing a pod or feature flag to babashka yourself would probably be the only way right now.
Here are some examples of feature flags: https://github.com/borkdude/babashka/blob/master/doc/build.md#feature-flags Here is more information about pods: https://github.com/babashka/babashka.pods
Is there anything like https://github.com/vadimdemedes/ink for building babashka based cli apps?
Kind of related, I think: https://github.com/phronmophobic/terminal-todo-mvc cc @U7RJTCH6J
the only thing that i've come across so far for the jvm is https://picocli.info/
@grahamcarlyle That doesn't do react-like rendering as far as I know? There is also react-blessed for node. I've gotten it to work with Reagent once.
i wasn't so much interested in ink for its react like api, though thats nice, i was interested in any libs that would support developing simple cli apps in babashka
Babashka comes with clojure.tools.cli as a library. There is also https://github.com/nubank/docopt.clj#babashka.
There's also work on cli-matic to make it compatible: https://github.com/l3nz/cli-matic/issues/113
More for coloured text rendering, and simple layout, basic input, progress bars etc.
$ export BABASHKA_CLASSPATH=$(clojure -Spath -Sdeps '{:deps {io.aviso/pretty {:mvn/version "RELEASE"}}}')
$ bb -e "(require '[io.aviso.ansi :as ansi]) (println (str \"The following text will be \" ansi/bold-red-font \"bold and red\" ansi/reset-font \".\"))"
Might be worth documenting at https://github.com/borkdude/babashka/blob/master/doc/libraries.md
Made an issue for that: https://github.com/borkdude/babashka/issues/547
@grahamcarlyle This ansi code is also pretty useful, for clearing the screen: https://twitter.com/borkdude/status/1278357459363602432
Here's an overview that should be usable to build some of this stuff maybe: http://ascii-table.com/ansi-escape-sequences-vt-100.php