This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-21
Channels
- # announcements (3)
- # babashka (98)
- # beginners (69)
- # chlorine-clover (6)
- # cider (24)
- # cljsrn (2)
- # clojure (97)
- # clojure-australia (2)
- # clojure-berlin (6)
- # clojure-dev (57)
- # clojure-dusseldorf (4)
- # clojure-europe (19)
- # clojure-italy (5)
- # clojure-nl (10)
- # clojure-seattle (1)
- # clojure-uk (44)
- # clojuredesign-podcast (13)
- # clojurescript (45)
- # cursive (4)
- # data-science (1)
- # datomic (32)
- # emacs (7)
- # events (5)
- # fulcro (17)
- # java (12)
- # jobs (1)
- # lumo (2)
- # malli (5)
- # observability (16)
- # off-topic (1)
- # pathom (3)
- # pedestal (4)
- # rdf (14)
- # re-frame (54)
- # reagent (4)
- # releases (3)
- # remote-jobs (1)
- # reveal (55)
- # shadow-cljs (34)
- # spacemacs (14)
- # specter (9)
- # tools-deps (16)
- # xtdb (7)
Hi, I'm attempting to create an uberscript, but when I execute the final file I'm getting this error:
line 1: ns: command not found
....
I'm creating this uberscript with this command BABASHKA_CLASSPATH=$(lein with-profile -dev classpath) bb -f src/demo/main.clj -m demo.main --uberscript demo.clj
On the resulting demo.clj
file, I see the main.clj
source and appended there's another line of code added.
I'm thinking that I'm using this command incorrectly, but I wasn't able to find any example.Ok this turned out being user error. I forgot to add the #!/usr/bin/env bb
to the top of the file before executing it 😛
babashka v0.2.3 released!
https://github.com/borkdude/babashka/blob/master/CHANGELOG.md#v023-2020-10-21
Featuring babashka/process: a new Clojure library around dealing with java.lang.Process
and many other additions and fixes.
do I need to do something else before using pods? bootleg
and clj-kondo
works fine
> (pods/load-pod "pod-babashka-hsqldb")
> java.io.IOException: Cannot run program "pod-babashka-hsqldb": error=2, No such file or directory [at <repl>:5:1]
@UFPEDL1LY If used from the local dir, you need to prepend it with "./"
like on the command line
btw about the aws pod: it uses the Go SDK under the hood so maybe you can find it in their docs
you’re everywhere @U04V15CAJ 😄 yeah looking at them now
Is it possible to change the default print method used by babashka? (How last form in the script is printed). For example, I'd like to try rendering it to the console with indenting + colors with puget.
Not sure if this is a good idea, but what about auto pprinting in some instances, like when connected to a terminal?
A more conservative option would be to make the print wrapper configurable, like prn -> puget/pprint
. Because then we could use preloads + that new option to make it work, I think
I have enabled puget in a branch. It does work, but it breaks piping.
$ /usr/local/bin/bb '{:a (repeat 10 {:a 1 :b 2 :c 3})}' | /usr/local/bin/bb '(:a *input*)'
({:c 3, :b 2, :a 1} {:c 3, :b 2, :a 1} {:c 3, :b 2, :a 1} {:c 3, :b 2, :a 1} {:c 3, :b 2, :a 1} {:c 3, :b 2, :a 1} {:c 3, :b 2, :a 1} {:c 3, :b 2, :a 1} {:c 3, :b 2, :a 1} {:c 3, :b 2, :a 1})
borkdude@MBP2019 ~/Dropbox/dev/clojure/babashka (puget*) $ ./bb '{:a (repeat 10 {:a 1 :b 2 :c 3})}' | ./bb '(:a *input*)'
Maybe puget can be made into its own GraalVM binary so you can pipe EDN to that and colorize it at will
I think such a tool will be very helpful in other contexts too. Any tool outputting EDN can then be piped into that
@U08JKUHA9 There's also a zprint GraalVM binary: https://github.com/kkinnear/zprint Maybe that also supports colors?
the reason I'm asking is, I have a pod for making TUIs: https://github.com/babashka/pod-babashka-lanterna but it doesn't work on Windows because of the terminal differences
I'm using Windows Terminal: https://docs.microsoft.com/en-us/windows/terminal/
I made a babashka puget branch. Can you maybe test it by running lein bb '{:a (repeat 10 {:a 1 :b 2 :c 3})}'
and then see what it prints?
I pushed a commit with --puget
. We might want to generalize this to --print-fn
which defaults to clojure.core/prn
but can be set to clojure.pprint/pprint
or puget/cprint
or whatever maybe?
I want to pay attention to the increase in compilation memory usage and binary size first before deciding on this
Also made these issues for it: - https://github.com/borkdude/babashka/issues/620 - https://github.com/greglook/puget/issues/53
@U08JKUHA9 it's done building here: https://ci.appveyor.com/project/borkdude/babashka
Hmm I get a problem:
PS C:\Users\isak.sky> bb '(range 5)'
(0 1 2 3 4)
PS C:\Users\isak.sky> bb --puget '(range 5)'
----- Error --------------------------------------------------------------------
Type: java.lang.Exception
Message: File does not exist: --puget
put --puget
as the last option. I implemented it so that --puget
can get an optional option
Ok now I don't get an error, but no colors/formatting:
PS C:\Users\isak.sky> bb -e '(into {:foo :bar} (for [i (range 10)] [i i]))' --puget
{0 0, 7 7, 1 1, 4 4, 6 6, 3 3, :foo :bar, 2 2, 9 9, 5 5, 8 8}
PS C:\Users\isak.sky> bb -e '(into {:foo :bar} (for [i (range 10)] [i i]))' --puget $true
{0 0, 7 7, 1 1, 4 4, 6 6, 3 3, :foo :bar, 2 2, 9 9, 5 5, 8 8}
PS C:\Users\isak.sky>
I did make https://github.com/greglook/edn-tool as a standalone tool a couple years ago, in any case. 😄
@U8XJ15DTK Nice. I just tried it. But I think the name should change to puget
or pprint
or something more akin to prettifying EDN
yeah it was going to be more general-purpose and support querying and transformation and such, but then https://github.com/borkdude/jet did all that 😅
semi related, thoughts on supporting CBOR in jet? https://github.com/greglook/clj-cbor
Nippy is not standardized, maybe that is why. (So you're unlikely to get implementations in other languages)
anyway to get back on point, I think a puget tool that only focuses on pprinting might be nice. I'm not sure if that fits with jet since it should then also colorize json output etc
Nippy is... It’s fast, but it’s not a standard so it’s clojure-only (including non-cljs). It does naive fallback to Java Serializable
, so if you don’t define a custom formatter for some type like org.joda.time.DateTime
it will blow up to hundreds of bytes when serialized. We also observed backwards-incompatible minor version changes, which broke all of our stored data. 😬 I would not recommend it.
I also like CBOR over transit+msgpack because it’s a lot simpler as a format and implementation, supports a wider variety of types, and is similarly more widely-supported (since transit is also clojure-specific). :man-shrugging:
@U8XJ15DTK sounds interesting. if CBOR is widely supported, maybe it's also a good candidate to add to pods as a wire format
pretty wide: http://cbor.io/impls.html
one of the explicit goals of the RFC is a simple/compact implementation in addition to compact message representation 😁 - so it’s pretty easy to write a codec
@U8XJ15DTK So if you decided to support a custom format, say a Clojure set, then I guess there is no standard way of decoding that in, say Go, right?
it’s a lot like EDN’s tagged literals; there is an IANA registry entry for “sets”, which are represented as an array of elements with tag 258
obviously in clojure those turn into #{}
but it’d be up to golang to decide what type to represent sets with - I’m guessing there’s similarly some native language type for them
The types most likely to be “weird” in other languages are keywords and symbols, which are ubiquitous in clojure but likely don’t have as direct a representation in other languages. You could define a handler for those tags to stringify them for a simple lossy conversion though, which is probably fine for things like map keys.
then there's also https://github.com/FasterXML/smile-format-specification
a lot of these binary formats (smile, msgpack, jsonb, etc) all fell into the same trap of, “like JSON, but binary!” without solving the type extension problem
@U04V15CAJ nice, got it working!